Fixed some file descriptors that were leaking