Fixed bugs on some MIDI functions.