tidying of path-related code

This PR largely affects the path handling. Behavior should be unchanged. To test, definitely try things like importing and downloading and other operations that affect repository file paths. Also make sure that there are no new FS test failures.