fix major bugs in template.clss