Don't make unexpected sate transitions.

Fixes #7.