Remove many references to solve lifetime issues.
Simplifies the code, primarily by changing &'a Rc<RefCell<&'a mut Template>>
to Rc<RefCell<Template>>
. Also removes some allocations.
Perhaps I'll see if I can simplify things further later tonight.