std::map is slow, switch to flat_map