Cleaned up MIDI functions