Refactored the Templating class and added a simple caching