Fixed bugs in the template