added code to enforce 20ms midi gap, code clean-up