Fixup cwd handling and various minor things