Fixed broken references to template variables.