To locate leaks, check for hissing sound. In addition, you may have to spray some carb cleaner at gaskets, joints and if the idle changes, then you found your leak.
Also try cleaning the MAF sensor.
http://www.contour.org/mods/mods.php?s=howto&displayid=36
and
http://www.contour.org/ubbthreads/showflat.php?Cat=&Board=zetecmaint&Number=989728&page=&view=&sb=5&o=&fpart=1&vc=1
and
http://www.autozone.com/servlet/UiBroker?ForwardPage=/az/cds/en_us/0900823d/80/1b/cb/25/0900823d801bcb25.jsp
Per TSB, some reasons for;
P0171 - System Too Lean (Bank 1) The Adaptive Fuel Strategy continuously monitors fuel delivery hardware. The code is set when the adaptive fuel tables reach a rich calibrated limit.
Fuel System:
�· Contaminated fuel injectors
�· Low fuel pressure or running out of fuel (fuel pump, filter, fuel supply line restrictions)
�· Vapor recovery system (VMV)
Induction System:
�· MAF contamination
�· Air leaks between the MAF and throttle body
�· Vacuum leaks
�· PCV system concern
�· Improperly seated engine oil dipstick
EGR System:
�· Leaking gasket
�· Stuck EGR valve
�· Leaking diaphragm or EVR
Base Engine:
�· Exhaust leaks before or near the HO2S
�· Secondary air concern
Powertrain Control System:
�· PCM concern
P0133,
HO2S Sensor Circuit Slow Response (HO2S-11) The HO2S monitor checks the HO2S sensor frequency and amplitude. If during testing, the frequency and amplitude were to fall below a calibrated limit, the code will set.
Electrical:
�· Shorted/open wiring
�· PCM
Induction System:
�· MAF sensor (On 4-cylinder engines, if P0133 is present, this could be caused by a MAF issue - on 6- and 8-cylinder engines, this could only be a MAF issue if P0133 and P0153 are both present)
�· Inlet air leaks (unmetered air)
Fuel Concerns:
�· Poor fuel quality
Base Engine:
�· Exhaust leaks (upstream or near HO2S)
HO2S Concerns:
�· Contaminated HO2S sensor (contamination from the use of silicone-based cleaners and sealants, leaded fuel, excessive oil consumption, etc.)
�· Deteriorating HO2S sensor
Before getting the O2 sensor, try cleaning the MAF sensor first.
For O2 sensors, try this thread.
http://www.contour.org/ubbthreads/showflat.php?Cat=&Board=v6maint&Number=1238895&Forum=v6maint&Words=o2%20sensor&Match=Entire%20Phrase&Searchpage=0&Limit=25&Old=3months&Main=1237746&Search=true#Post1238895