Refactoring and adding templates.