Switch to unordered_map for faster lookups.