beginning to refactor machine to use union types of nodes and definitions better. more verbose, but clearer and more extensible