Fixed some template-related issues