Bug fix for templates