Fix problems when deleting files