Fix some bugs in template.