Fixed issue where file descriptor limit could be hit