Memoize and simplify parts of insertion.
Memoize and simplify parts of insertion.

mozilla/mentat,ncalexan/mentat,ncalexan/mentat,ncalexan/mentat,ncalexan/datomish,mozilla/mentat,mozilla/mentat,ncalexan/mentat,mozilla/mentat,ncalexan/mentat,ncalexan/mentat,bgrins/datomish,bgrins/datomish,mozilla/mentat,ncalexan/datomish,mozilla/mentat