add missing imports
fix leaking file descriptor bug