public boolean fixIntegrity() {
        for (AIObject ao : new ArrayList<AIObject>(aiObjects.values())) {
            if (!ao.checkIntegrity()) {
                logger.warning("Dropping invalid AIObject: " + ao.getId()
                    + " (" + ao.getClass() + ")");
                ao.fixIntegrity();
            }
        }

        Iterator<FreeColGameObject> fit
            = getGame().getFreeColGameObjectIterator();
        while (fit.hasNext()) {
            FreeColGameObject f = fit.next();
            if ((f instanceof Unit
                 || f instanceof Colony
                 || (f instanceof Player && !((Player)f).isUnknownEnemy()))
                && !aiObjects.containsKey(f.getId())) {
                logger.warning("Added missing AIObject for: " + f.getId());
                setFreeColGameObject(f.getId(), f);
            }
        }

        return checkIntegrity();
    }