Readability improvements to the interval/merging code

Based on code review by Daniel.