public static List<CDDFeature> removeOverlaps(List<CDDFeature> features) {
		List<CDDFeature> newFeatures = new ArrayList<CDDFeature>();
		CDDFeature lastFeature = null;
		Collections.sort(features);
		for (CDDFeature feature: features) {
			// System.out.println("Looking at "+hit);
			if (lastFeature == null || feature.getFrom() > lastFeature.getTo()) {
				// System.out.println("Adding "+hit);
				newFeatures.add(feature);
				lastFeature = feature;
			} else {
				// They overlap.  Figure out which one to show.
				int index = newFeatures.size()-1;
				// Is it a complete overlap?
				if (lastFeature.getFrom() == feature.getFrom() && 
				    lastFeature.getTo() == feature.getTo()) {
					// Yes, we're done
					continue;
				} else {
					// Is the second feature within the first feature?
					if (feature.getTo() <= lastFeature.getTo()) {
						// System.out.println("Splitting "+lastFeature.getName());
						// Yes, insert it and split lastFeature
						CDDFeature truncatedFeature = 
							new CDDFeature(lastFeature.getProteinId(),lastFeature.getAccession(), 
						                 lastFeature.getFeatureType(), lastFeature.getFrom(), feature.getFrom());
						// System.out.println("Updating "+truncatedFeature);
						newFeatures.set(index,truncatedFeature);
						// System.out.println("Adding "+hit);
						newFeatures.add(feature);
						lastFeature = feature;
						if (lastFeature.getTo() > feature.getTo()) {
							truncatedFeature = 
								new CDDFeature(lastFeature.getProteinId(),lastFeature.getAccession(),
							                 lastFeature.getFeatureType(), feature.getTo(), lastFeature.getTo());
							// System.out.println("Adding "+truncatedFeature);
							newFeatures.add(truncatedFeature);
							lastFeature = truncatedFeature;
						}
						continue;
					}

					// More complicated.  We need to truncate the first one
					CDDFeature truncatedFeature = 
						new CDDFeature(lastFeature.getProteinId(),lastFeature.getAccession(), 
						               lastFeature.getFeatureType(), lastFeature.getFrom(), feature.getFrom());
					// System.out.println("Updating "+truncatedFeature);
					newFeatures.set(index,truncatedFeature);
					// System.out.println("Adding "+feature);
					newFeatures.add(feature);
					lastFeature = feature;
				}
			}
		}
		return newFeatures;
	}