Optimizations to the code