Simplify state class.

Tweak some things.
More suitable error messages.