Refactored view/layout code