more cleanup of the priority algorithm code.