Fixed bugs in templates.