Use DenseMap instead of std::map for efficiency