Mine had the same issue for a while. Cleaned the throttle body, changed the spark plugs to new ...and cleaned the MAF and that resolved it. You may want to take another look at the TB just in case. And clean/replace the PCV ..which can also do that. Also worth checking the vacuum hoses and re-look at the sensors since you had the engine out. Although you probably already did that. Sounds like you know what you're doing.
Also, sometimes I've seen the main rubber intake hose which goes to the TB can 'fold' under during installation and be out of place under the clamp at the TB. It would be easy to do and impossible to see it wasn't sealing 'right'. The PO of my vehicle had it like that when I bought it and I didn't notice it for quite a while. That would allow air to be sucked through the gap of the hose and the main computer to 'think' it was getting less air than was going past the MAF. And would screw with what the fuel mapping. Less noticable at higher speed than at idle when less air is going past. So worth pulling off the hose and checking that.
If you have a scanner, double-check the temp sensor is reading right. Finally, MAF's don't always respond to cleaning. I had a vehicle a few yrs ago where the MAF was at the lower end of the 'good' range, after cleaning a couple times, but still idled like crap. It wasn't right on the edge ..I assumed it was fine. After exhausting every other possibility, resetting the computer, etc ...I finally broke down and bought a new Bosch MAF and BINGO! instantly ran great. It bought the voltage reading (via the OBD) into a higher range. So, on that vehicle, in that instance, it must have been too low in the range. But before you do that, quadruple-check the other things on my and other guys' forum posts. You could unhook the MAF too and drive it and see if that runs ok (in open loop mode) to see.
In addition, you may also ohm out the coils. Put a vacuum gauge on the intake and watch needle, see if you have any lingering intake leaks. Wave a propane hose around in the engine compartment to see if it levels off. Check injector seals, etc. But start with the TB/hose/PCV, etc. Problems are usually the small things.
That's about all I can think of. Let us know what it turns out to be...