Support for visitor pattern. Also switched nodes to inheritance and pointers.