fixed "too many open files" exception