Generate ident's for TemplateInstance's lazily

2nd try at this. Reduces ident generation by 75%.