Precalculate name and code maps for fast lookup.

Maybe this is premature optimisation but we'll be doing this a bunch and it is a simple improvement.