Move around some type definitions.
First proper pass on DFS - tests say it works