Set up state_machine