private void optimize(int i) {
		// look to see if there is overlap like this:
		// t: <---i>
		// t:   <----->
		if (i == size - 1) {
			return;
		}
		
		int j = i + 1;
		while (j < size && ranges[j] <= ranges[i]) {
			j += 1;
		}
		if (j == size) {
			size = i + 1;
		} else {
			int d = j - i - 1;
			if (d % 2 == 0) {
				// t: <----i>
				// t:   ...
				// t:          <j----> 	

				if (ranges[j] == ranges[i] + 1) {
					ranges[i] = ranges[j + 1];
					j += 2;
					d += 2;
				}
				// shrink below
			} else {
				// t: <----i>
				// t:   ...
				// t:     <----j> 	

				ranges[i] = ranges[j];
				j++;
				d++;
			}
			
			// shrink
			for (int k = j; k < size; k++) {
				ranges[k - d] = ranges[k];
			}
			size -= d;
		}
	}