Cache fixes, e.g. after pathsubstituion

As folders are saved after substitution, a file lookup will fail as the folder name will not be substituted when doing the lookup.
As for the other commit, shouldn't a file be readded after a rename?