Fixing toSet and toMap to throw when not found