Speedup -- replace hash table with bsearch.