Prevent exception when a template is deleted