Refactor templates and stylesheets