New MIDI code with new State Machine