Refactor to directives for the main page.