Replace map with unordered_map nearly everywhere, for speed.