Refactor templates and styles