Fixed bug in merge_ranges.