Refactor main application layout