P0171 would not generate from a thermostat problem, incidentally there are certain codes that can set due to engine temp/thermostat concerns, especially when they are stuck op and running too cool.
P0171 means the engine (bank 1) is running too lean, lean to the point where the PCM attempted to add extra fuel and reached its limit of compensation and its still too lean. Vacuum leaks (vac lines/hoses, intake gasket etc are usually the culprit but a fuel supply/delivery problem often cause problems too among a few other things.
The p0138,p0158 are for the rear oxygen sensors behind the catalytic converters (after cat) indicating excessive voltage. Possible causes are faulty cats, shorted/melted sensors or wiring.
The p0420,p0430 codes generate from the rear sensors too. These codes trip when the PCM sees the rear sensors mimicking the front sensor switch rate which means the cats are not cleaning the exhaust emissions to a specific level. Most likely cause is the catalytic converters. Often times driving a vehicle with excessive misfiring can burn out the cats from excessive heat generated from unburned fuel.
The p0300 is typical when an engine simply runs rough and not on a particular cylinder or random. Many things can cause this from typical tune up items, sensors-ignition, mechanical problems, fuel problems, sensors, among the same things listed above with p0171. Since you are taking the dist cap off, verify the rotor or dist shaft does not have excessive play when turning back/forth. I have seen a few of these trucks with worn gears on the dist, also some worn dist shafts too.
So, basically I would try to look into the P0171 and P0300 running problem first, the other codes maybe related to the running problem from these two codes.
Sorry for the long post, I dont want to add more right now but if you check some stuff out then repost and maybe we can help narrow things down.
Same-Day Shipping! Most of our stocked parts ship the same day you order (M-F). Expedited shipping available, just call! Most prices for parts and manuals are below our competitors. Compare our super low shipping rates! We have the parts you need to repair your tractor. We are a Company you can trust and have generous return policies! Shop Online Today or call our friendly sales staff toll free (800) 853-2651. [ More Info ]
TRADEMARK DISCLAIMER: Tradenames and Trademarks referred to within Yesterday's Tractor Co. products and within the Yesterday's Tractor Co. websites are the property of their respective trademark holders. None of these trademark holders are affiliated with Yesterday's Tractor Co., our products, or our website nor are we sponsored by them. John Deere and its logos are the registered trademarks of the John Deere Corporation. Agco, Agco Allis, White, Massey Ferguson and their logos are the registered trademarks of AGCO Corporation. Case, Case-IH, Farmall, International Harvester, New Holland and their logos are registered trademarks of CNH Global N.V.