Refactor if..else into a switch.

Also support the hidden and suspended states.