In my still stashed reliable delivery branch I used an Array based ring buffer addressed by seqNo & Mask and explicitly storing a Gap object to denote missing pieces. I think a similar approach would work here, eliminating the need for the TreeSet and Ordering. (it's a quasi bucket-sort, and if the window is short, it works quite well).