I have had cars in the shop do the same thing after doing engine service and the battery was unhooked for a while. More times than not- when you need the transmission adapts to reset with a trans install they dont reset and you have to do it with a scan tool, go figure. Unfortunately your pcm has been learning for a very long time as your transmission ages and adapts to this. I have had cars that even after a week of stop and go driving just dont feel any better or at all like they used to and had to tweak the tune a bit just to get them back to normal. 167K miles is not on your side and it is going to take time to relearn but may be out past the point of no return and the quick easy bandaid is installing a Transgo shift kit as that has proven to help out more times than not in situations like this. The more shift cycles and key cycles the car gets the faster it learns, so if you do a lot of highway driving it is going to take a long time to get back on track if it does at all. It is best to try NOT to drive the car hard if you dont have to until things start to feel better.