Getting rid of extraneous use of LinkedHashSet (plain old HashSet will suffice).
Beefing up asserts (slightly).