Lots of template re-organizing
merge the template refactoring