Refactor the main layout