Make list operations O(1)

The python implementation (and thus the original code) had poor
performance due to all the linear scans through the linked-lists.  This
patch augments all the lists with a hash table mapping key->node to
allow all list operations to be O(1) instead.