Fix get_valid_ranges.