Integrate TemplateRules plugin with the core
Refactor code for when all templates are allowed.