MIDI import: further optimization and fixes

Only few MIDI files were checked but the import is quite fast even in Debug mode.