Reduced the amount of global lookups.

 * In doing so, found two bugs and squashed
   them.