Check hose between the air filter and the throttle body for cracks. Lazy people will bend that hose when checking or changing the air filter. This will allow in unmetered air causing a lean condition.
I've been fighting with a P0171 code than comes and goes. Finally found a crack in the air tube between the air cleaner and the throttle body. This messes the mass air flow sensor readings. I do all my own maintenance, but take my car for it's yearly alignment at a chain store where I bought a...