Starting refactor of template manager