public void clean() {
        State st = null;
        List<Character> toRemove = new ArrayList<Character>();
        for(Character c : next.keySet()) {
            st = next.get(c);
            if(st.deleted && !st.needed) {
                st.forceClean();
                st = null;
                toRemove.add(c);
            } else {
                st.clean();
            }
        }

        for(Character c : toRemove) {
            next.remove(c);
        }
    }