Collect template information once (sort of pre-compile template node), apply prepared values n times. Phase 1 - handle property and reference macros.
Template node runtime: phase 2 - handle references
It's not a nice idea to catch StackOverflowError. First of all, there should be no stack overflow (and I've did quite some job to keep stack slim). Second, the advice to increase stack size is redundant - it's the only (and btw incorrect) workaround. Third, backtrace (with tracer we're not going to support) is unlikely to help user to decrease the stack (and not to get into the issue again). That's why it's reasonable to fail aloud and let user complain to MPS team.