Use std::map for do_mode_cnt

It appears its performance is even better than our hash table...
Optimize unique for performance