Uses std::unordered_map<> instead of std::map<>

and more fixes.