Fixed a 'too many open files' issue