public Unit getBetterExpert(Unit expert) {
        GoodsType production = expert.getWorkType();
        GoodsType expertise = expert.getType().getExpertProduction();
        Unit bestExpert = null;
        int bestImprovement = 0;

        if (production == null || expertise == null
            || production == expertise) return null;

        // We have an expert not doing the job of their expertise.
        // Check if there is a non-expert doing the job instead.
        for (Unit nonExpert : getUnitList()) {
            if (nonExpert.getWorkType() != expertise
                || nonExpert.getType() == expert.getType()) continue;

            // We have found a unit of a different type doing the
            // job of this expert's expertise now check if the
            // production would be better if the units swapped
            // positions.
            int expertProductionNow = 0;
            int nonExpertProductionNow = 0;
            int expertProductionPotential = 0;
            int nonExpertProductionPotential = 0;

            // Get the current and potential productions for the
            // work location of the expert.
            WorkLocation ewl = expert.getWorkLocation();
            if (ewl != null) {
                expertProductionNow = ewl.getPotentialProduction(expertise,
                    expert.getType());
                nonExpertProductionPotential
                    = ewl.getPotentialProduction(expertise,
                        nonExpert.getType());
            }

            // Get the current and potential productions for the
            // work location of the non-expert.
            WorkLocation nwl = nonExpert.getWorkTile();
            if (nwl != null) {
                nonExpertProductionNow = nwl.getPotentialProduction(expertise,
                    nonExpert.getType());
                expertProductionPotential
                    = nwl.getPotentialProduction(expertise,
                        expert.getType());
            }

            // Find the unit that achieves the best improvement.
            int improvement = expertProductionPotential
                + nonExpertProductionPotential
                - expertProductionNow
                - nonExpertProductionNow;
            if (improvement > bestImprovement) {
                bestImprovement = improvement;
                bestExpert = nonExpert;
            }
        }
        return bestExpert;
    }