Get directory name before going gc-free.  Throw error if directory fails to open.  Remove some compile warnings