private void cleanUpImports() {
		Integer dummyVote = new Integer(Integer.MAX_VALUE);
		SortedMap newImports = new TreeMap(comparator);
		List classImports = new LinkedList();
		Iterator iter = imports.keySet().iterator();
		while (iter.hasNext()) {
			String importName = (String) iter.next();
			Integer vote = (Integer) imports.get(importName);
			if (!importName.endsWith(".*")) {
				if (vote.intValue() < importClassLimit)
					continue;
				int delim = importName.lastIndexOf(".");

				if (delim != -1) {
					/*
					 * Since the imports are sorted, newImports already contains
					 * the package if it should be imported.
					 */
					if (newImports.containsKey(importName.substring(0, delim)
							+ ".*"))
						continue;

					/*
					 * This is a single Class import, that is not superseeded by
					 * a package import. Mark it for importation, but don't put
					 * it in newImports, yet.
					 */
					classImports.add(importName);
				} else if (pkg.length() != 0) {
					/*
					 * This is a Class import from the unnamed package. It must
					 * always be imported.
					 */
					newImports.put(importName, dummyVote);
				}
			} else {
				if (vote.intValue() < importPackageLimit)
					continue;
				newImports.put(importName, dummyVote);
			}
		}

		imports = newImports;
		cachedClassNames = new Hashtable();
		/*
		 * Now check if the class import conflict with any of the package
		 * imports.
		 */
		iter = classImports.iterator();
		while (iter.hasNext()) {
			/*
			 * If there are more than one single class imports with the same
			 * name, exactly the first (in sorted order) will be imported.
			 */
			String classFQName = (String) iter.next();
			if (!conflictsImport(classFQName)) {
				imports.put(classFQName, dummyVote);
				String name = classFQName.substring(classFQName
						.lastIndexOf('.') + 1);
				cachedClassNames.put(classFQName, name);
			}
		}
	}