freeze frame is the data information that the computer saves when a hard code is set. It is part of the OBD2 diagnostics. it will tell you what was happening when the code was set.
Fuel trim is what the computer is setting the fuel parameter to, so that the oxygen sensor
will read within spec. It has a short term value and a long term value. It tells you if the computer is adding fuel or subtracting fuel to compensate for problem according to the oxygen readings.
If your MAF reading is low your computer will send a low amount of fuel. and normally that's fine. But if your MAF is low because it is inaccurate the computer will send a low amount of fuel and your oxygen sensor
will see too much oxygen in the exhaust. (a lean condition). The fuel trim will go up to compensate. If fuel trim has to go up too much you will set the code for lean condition. It could be MAF signal too low. Vacuum leak in the system somewhere. Bad oxygen sensor. bad or poor injector output. Low fuel pressure or volume. misfire. even a bad PCM.
looking at the data stream graphs with a scanner while you're driving will help narrow what to look for.
so, you had a code for the MAF and you replaced it. Then you started to have the P0171 codes come up? If it happened just like that maybe your MAF isn't working correctly.