Refactored the template engine to support multiple targets