Optimizations to code