layout cleanup and optimizations