Update state machine

Fix callback args overriding
Merge pull request #2072 from winzou/update-state-machine

Update state machine