Fixed flatten when deleting directories