diff --git a/indexation.cabal b/indexation.cabal
--- a/indexation.cabal
+++ b/indexation.cabal
@@ -1,5 +1,5 @@
 name: indexation
-version: 0.6.4
+version: 0.6.4.1
 category: Data
 synopsis: Tools for entity indexation
 description: A set of tools for indexing entities
@@ -43,7 +43,7 @@
     contravariant >=1.4 && <2,
     deepseq >=1.4.3 && <2,
     deferred-folds >=0.9.6 && <0.10,
-    dense-int-set >=0.1.5 && <0.2,
+    dense-int-set >=0.2 && <0.3,
     focus >=1.0.1 && <1.1,
     foldl >=1 && <2,
     hashable >=1 && <2,
diff --git a/library/Indexation/Functions.hs b/library/Indexation/Functions.hs
--- a/library/Indexation/Functions.hs
+++ b/library/Indexation/Functions.hs
@@ -47,10 +47,10 @@
 countIndexSet (IndexSet set) = DenseIntSet.size set
 
 newIndexToOldIndexTable :: IndexSet a -> EntityTable (Index a)
-newIndexToOldIndexTable (IndexSet set) = EntityTable (coerce (DenseIntSet.presentElementsVector set :: Vector Int))
+newIndexToOldIndexTable (IndexSet set) = EntityTable (DenseIntSet.presentElementsVector set Index)
 
 oldIndexToNewIndexTable :: IndexSet a -> ReindexTable a
-oldIndexToNewIndexTable (IndexSet set) = ReindexTable (DenseIntSet.indexVector set)
+oldIndexToNewIndexTable (IndexSet set) = ReindexTable (DenseIntSet.indexVector set id)
 
 filterEntityTable :: IndexSet a -> EntityTable a -> EntityTable a
 filterEntityTable (IndexSet set) (EntityTable vec) = EntityTable (DenseIntSet.filterVector set vec)
diff --git a/library/Indexation/Utils/Vector.hs b/library/Indexation/Utils/Vector.hs
--- a/library/Indexation/Utils/Vector.hs
+++ b/library/Indexation/Utils/Vector.hs
@@ -6,6 +6,7 @@
 import qualified Data.Vector.Mutable as MutableVector
 import qualified Data.HashMap.Strict as HashMap
 import qualified DeferredFolds.UnfoldlM as UnfoldlM
+import qualified DeferredFolds.Unfoldr as Unfoldr
 import qualified ListT
 
 
@@ -34,13 +35,17 @@
 -}
 {-# INLINE indexHashMapWithSize #-}
 indexHashMapWithSize :: Int -> HashMap element Int -> Vector element
-indexHashMapWithSize size hashMap =
+indexHashMapWithSize size = unfoldrWithSize size . fmap swap . Unfoldr.hashMapAssocs
+
+{-|
+This function is partial. It doesn't check the size or indices.
+-}
+{-# INLINE unfoldrWithSize #-}
+unfoldrWithSize :: Int -> Unfoldr (Int, element) -> Vector element
+unfoldrWithSize size unfoldr =
   runST $ do
     mv <- MutableVector.new size
-    HashMap.foldrWithKey
-      (\ element index action -> MutableVector.write mv index element >> action)
-      (return ())
-      hashMap
+    Indexation.Prelude.forM_ unfoldr $ \ (index, element) -> MutableVector.write mv index element
     freeze mv
 
 {-# NOINLINE unfoldlM #-}
