Midi improvements and some other misc stuff
More flexible midi parser. Lots of other misc fixes.