optimizations and layout