Fix SetPartitions type parameter
Also speed up SetPartitions iteration