Did some initial work on the hierarchical state machine.