fixed some template bugs