Added MIDI capabilities, refactored a lot of the code.