[RFC] Refactor codebase

cc @mlubin @IainNZ 
Are there other kinds of nodes in this context?