Fixes exception while removing template