If state was defined as a class variable then different instances of a class would clobber each other. Updated the code to create a new instance of state for each instance of a FiniteStateMachine.