Lots of detail optimizations