fix bugs
fix too many open files bugs