Fixed bug in template.html and other bugs in templates