Curious as to how distance from TB/engine would be the key factor.
AFAIK, the tubing before and after would be the primary influences on accuracy.
Having the MAF right after the filter means it might not be seeing the most laminar airflow that it could be. However a similar issues applies to having a bend before the MAF as well.
As for the stock intake being better than a HAI, I would agree. The stock setup is essentially a quite "CAI".
Unsure on what specifically is causing your issues.
I find if the fuel trims are out of wack, it will struggle to find an idle in similar situations as you've described. Its very likely these are off as you had the HAI installed, and the PCM adapted to that.
Since you've reinstalled the stock air box, I would suggest disconnecting the battery in hopes of resetting the fuel trims. Some say you should connect the neg/pos battery cables as apparently this causes a reset of the trims/trans adapt settings.