A bunch of optimizations