This removes some of the complexity that existed before (e.g. too many state machines) and fixes a bunch of problems with nested data.