Refactor main layout