Refactored the TemplateGenerator class

This allows the integration of the module into Horizon.