fixed template bugs.