Added handling for $stateChangeError. Fixes #55