Working on the State machine and different modes.