Makes StateMachine synchronized on handler to avoid threading issues