Modified code to use HashMap in a few places for (hopefully) increased performance.
Implemented a better hash function for CharSet, since it's critical for good performance with HashMap.