fix some template bugs