Refactor state machine cycle handling. Updates to control tests.