i beleve that P0171 code is Catalyst system efficency below threshold. Meaning your emissions is below standard. If you have already cleaned the MAF sensor and replaced all those other parts mentioned, your cat is at fault and replacement would be the only fix. I had this problem with my 99 2.7L tacoma. i did all the things you did, and still getting p0171 after 2-3 miles. replaced the cat and code never came back.
then about a month later my truck was bought back because of Frame Peferations! what a waste of a grand!!
then about a month later my truck was bought back because of Frame Peferations! what a waste of a grand!!