Fix state reset logic
Merge pull request #217 from n1ywb/master

Fix state reset logic