use more apt variable names in various bash functions

Also, remove various unused variables some of which relate to legacy
portage code which has been removed or rewritten.