handle empty directories, clean up base path