Fix bug if template is cached