rename function for clarity
fix bugs in serialization of sets.