fix some misplaced set_dir()s

fixes part of #7284
fixes #7288
fixes one of #7287