Small optimizations

#9 Improved some loop caches