Improve path handling with basedir