replacing calls to random with SeededRandom
converted to LinkedHashMap/LinkedHashSet for deterministic ordering