Resolve problems with folder deletion.

In some cases, DirectoryTidier makes checkins fail. See #313.

One solution is in #320.

This one is a WIP, for now.