I believe I know what's the problem here. Let's say that you have an original MIDI file with the following ordered MIDI events (I am not adding a time stamp for each one of them for the sake of simplicity -- like real MIDI files have -- so just think of them as ordered):
That is, a note C starts then finishes, then a note G is held, a note F starts and finishes, and then finally that G that is still sounding is released. So now if we randomly add numbers between 1-4 to these notes, this is what happens:
A note C# starts, a note E stops (but it was not being played anyway), a note D# is played and then again (without a note off in between), then a note D and a note E stop (though they were also not being played). This means that the notes C# and D# are still being played and will forever (or more exactly, until you turn off your computer )
Thus, you can see that since the note on and note off events should have the same MIDI note value, randomizing them is not a good idea (at least not with this method of yours). That's why the notes are hanging when the [random] objects is being used, and why they work just fine without it.
Hope this helps,