Fix many of the regressions with MIDI recording since the engine was reworked.

Still a few outstanding issues though...