Fixed bugs in template files