Simplified some calculations in the layout container