Refactors how layout is working