smart_chdir fix