Various changes to make MIDI work with JACK.
Change to parsing to detect trailing 'if' etc.