Initial work on c++ state machine code (IN PROGRESS). Includes a test.