State machine fixes