Fixed memory leaks in Dir#working_directory and File#expand_path