Optimize layout