Fix bug with templates being undefined