Fixes #461
Fixes bug when deleting cms templates