Minor improvements to util.midi