added @mlubin's suggestions for indexing to preserve KeyIndex and others O(1)