A bit of refactor
More refactor
Migrating towards to FSM implementation

Migrating towards to FSM implementation
Whitespace fixes