Fix thresholds, implement duplicate_foreach for filesystem