Code Formatting changes.

Also removed blocks from case statements. Renamed some variables
and changed their scope (next events / next states).