more refactoring
don't take dirfd for package loading either