State machine - Fix overflow in states