Some very minor optimizations. Remove little-used stat counter.
Use unordered_map where it makes sense. Very tiny speed boost?

Also some microoptimizations.