Changed how assignment from temporary variables are eliminated.
Optimized foreach() with index