Optimizations and formatting