removing some nondeterminism by replacing HashSet's with LinkedHashSet's