DEBUG var fixes , state machine fixes