Adding control FSM to control behaviour at core level. More cleanup.