Minor improvements to the code. State machine updated