public void tidyUp(final Collection<String> varsNeeded) {

        final Collection<String> varsNeededNonNull = varsNeeded == null ? Collections.emptySet() : varsNeeded;

        //1. add all missing vars if any
        for (String v : varsNeededNonNull) {
            if (!contains(v)) {
                addVariable(v, "");
            }
        }

        //2. remove empty vars which are not needed by anyone
        final Set<String> toRemove = new HashSet<>();
        for (String v : variableMap.getVars()) {
            if (!varsNeededNonNull.contains(v) && variableMap.isEmptyAndNotNeeded(v)) {
                toRemove.add(v);
            }
        }
        for (String tr : toRemove) {
            removeVariable(tr);
        }

        //3. add empty entries for all vars still missing
        for (String nullVar : variableMap.getNullEntries()) {
            addVariable(nullVar, "");
        }

        //4. sort variables
        sortVariables(TextUtils.COLLATOR::compare);
    }
Tidies up this variable list. This means doing the following things:
* remove empty entries without dependency of any other var (or from varsToKeep list)
* add empty entries for all missing vars
* sorts vars alphabetically
main/src/main/java/cgeo/geocaching/utils/formulas/VariableList.java