Fixed IOError too many files open bug