Fixing some bugs in read_dir; still not working.