Fix variable references in template