Fix IndexOutOfRange exception in HashSet (triggered by multiple threads)
Use dictionary as hashset now.