handle unexpected states; closes #570
Merge remote-tracking branch 'origin/master'