Small optimization for parsing templates, added const where possible.