Added check of duplicate template variables. But, it is a bad solution. I'm going to rewrite.