Speed optimizations and prettify