Fix too many open files issue