Refactoring templates and other stuff.