Refactor templates to use a base template