Convert node to a template

This is a mess: essntially node is a template, but to instantiate it
you need to have a node -- it's a recursive template!

Oddly enough it seems possible to break this dependency by specifying
a sub class of node and passing that as the template argument, but it
feels pretty wacky to me...