Make SumOfProducts a class to avoid serialization issues