Merge "Improved and simplified loop optimizations." am: c1f24b947a
am: 18173e50b8

Change-Id: If1555e3bcfec791c94d7569fc667f44783d14cc5