Make FiniteWeightedList more generic