Fixing toSet/toWeakSet issues