move which_prefix() and which_package() into misc module