Removing unreferenced templates