You said that there was a lot of oil on the K&N filter. Check the MAF sensor elements if they have any oil on them if they do clean it with some MAF cleaner.
you are on the money mate
A code P0171 may mean that one or more of the following has happened:
The MAF (Mass Air Flow) Sensor is dirty or faulty. Note: The use of "oiled" air filters may cause the MAF to become dirty if the filter is over-oiled. There is also an issue with some vehicles where the MAF sensors leak the silicone potting material used to protect the circuitry.
There could be a vacuum leak downstream of the MAF sensor.
Possible Solutions
Possible solutions include:
In the vast majority of cases, simply cleaning the MAF sensor does the trick. Consult your service manual for it's location if you need help. I find it's best to take it off and spray it with electronics cleaner or brake cleaner. Make sure you are careful not to damage the MAF sensor, and make sure it's dry before reinstalling
Inspect all vacuum and PCV hoses, replace if necessary
Check for a dirty fuel filter and proper fuel pressure.
all is well.
Everyone else can relax, for a moment i thought i was talking about your car lol