Calculator brain clean up.

Revised state machine.