diff --git a/indexation.cabal b/indexation.cabal
--- a/indexation.cabal
+++ b/indexation.cabal
@@ -1,7 +1,7 @@
 name:
   indexation
 version:
-  0.2.1
+  0.3
 category:
   Data
 synopsis:
@@ -41,17 +41,14 @@
   default-language:
     Haskell2010
   exposed-modules:
-    Indexation.EntityTable
-    Indexation.Index
-    Indexation.IndexTable
+    Indexation.Data
     Indexation.IO
-    Indexation.Potoki.Produce
     Indexation.Potoki.Transform
   other-modules:
     Indexation.Cereal.Get
     Indexation.Cereal.Put
     Indexation.Constructors.EntityTable
-    Indexation.Folds
+    Indexation.Instances
     Indexation.Instances.Cereal
     Indexation.Prelude
     Indexation.Types
@@ -62,13 +59,12 @@
     cereal >=0.5.5 && <0.6,
     deferred-folds >=0.6 && <0.7,
     focus >=1.0.1 && <1.1,
-    foldl >=1 && <2,
     hashable >=1 && <2,
-    potoki-cereal >=0.3 && <0.4,
     potoki >=2 && <2.1,
+    potoki-cereal >=0.3 && <0.4,
     profunctors >=5.2 && <6,
     stm-containers >=1 && <1.1,
-    transformers >=0.5 && <0.6,
     text >=1 && <2,
+    transformers >=0.5 && <0.6,
     unordered-containers >=0.2.9 && <0.3,
     vector >=0.12 && <0.13
diff --git a/library/Indexation/Data.hs b/library/Indexation/Data.hs
new file mode 100644
--- /dev/null
+++ b/library/Indexation/Data.hs
@@ -0,0 +1,10 @@
+module Indexation.Data
+(
+  Index(..),
+  EntityTable,
+  Indexer,
+)
+where
+
+import Indexation.Types
+import Indexation.Instances ()
diff --git a/library/Indexation/EntityTable.hs b/library/Indexation/EntityTable.hs
deleted file mode 100644
--- a/library/Indexation/EntityTable.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module Indexation.EntityTable
-(
-  EntityTable,
-  indexTable,
-  lookup,
-)
-where
-
-import Indexation.Prelude hiding (lookup)
-import Indexation.Types
-import Indexation.Instances.Cereal ()
-import Indexation.Constructors.EntityTable
-import qualified Data.Vector as B
-
-
-lookup :: Index entity -> EntityTable entity -> Maybe entity
-lookup (Index indexPrim) (EntityTable vector) =
-  vector B.!? indexPrim
diff --git a/library/Indexation/Folds.hs b/library/Indexation/Folds.hs
deleted file mode 100644
--- a/library/Indexation/Folds.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module Indexation.Folds
-where
-
-import Indexation.Prelude
-import Indexation.Types
-import Control.Foldl
-import qualified Data.HashMap.Strict as B
-
-
-indexTable :: (Eq entity, Hashable entity) => Fold entity (IndexTable entity)
-indexTable =
-  Fold step init extract
-  where
-    init = IndexTable 0 B.empty
-    step (IndexTable index map) key =
-      case B.lookup key map of
-        Just _ -> IndexTable index map
-        Nothing -> let
-          newMap = B.insert key index map
-          newIndex = succ index
-          in IndexTable newIndex newMap
-    extract = id
diff --git a/library/Indexation/IO.hs b/library/Indexation/IO.hs
--- a/library/Indexation/IO.hs
+++ b/library/Indexation/IO.hs
@@ -1,17 +1,20 @@
 module Indexation.IO
 (
+  Indexer,
+  EntityTable,
   createIndexer,
+  getIndexerSize,
+  freezeIndexerAsEntityTable,
+  serializeEntityTableToFile,
   serializeIndexerToFile,
-  indexProduceToFiles,
   readEntitiesAmountFromEntityTableFile,
   readEntityTableFromFile,
-  readIndexTableFromFile,
 )
 where
 
 import Indexation.Prelude
 import Indexation.Types
-import Indexation.Instances.Cereal ()
+import Indexation.Instances ()
 import qualified Potoki.IO as PotokiIo
 import qualified Potoki.Produce as PotokiProduce
 import qualified Potoki.Consume as PotokiConsume
@@ -30,36 +33,30 @@
   map <- StmMap.newIO
   return (Indexer sizeVar map)
 
-createIndexerVector :: Indexer entity -> IO (Vector entity)
-createIndexerVector (Indexer sizeVar map) =
+getIndexerSize :: Indexer entity -> IO Int
+getIndexerSize (Indexer sizeVar _) = atomically (readTVar sizeVar)
+
+freezeIndexerAsVector :: Indexer entity -> IO (Vector entity)
+freezeIndexerAsVector (Indexer sizeVar map) =
   atomically $ do
     size <- readTVar sizeVar
     Vector.unfoldM size (fmap swap (StmMap.unfoldM map))
 
-createIndexerEntityTable :: Indexer entity -> IO (EntityTable entity)
-createIndexerEntityTable = fmap EntityTable . createIndexerVector
-
-serializeProduceEntityIndicesToFile :: (Eq entity, Hashable entity) => FilePath -> Indexer entity -> Produce entity -> IO (Either IOException ())
-serializeProduceEntityIndicesToFile path indexer entityProduce =
-  PotokiIo.produceAndConsume entityProduce $
-  PotokiConsume.transform (PotokiTransform.indexConcurrently indexer) $
-  PotokiConsume.encodeToFile path
+freezeIndexerAsEntityTable :: Indexer entity -> IO (EntityTable entity)
+freezeIndexerAsEntityTable = fmap EntityTable . freezeIndexerAsVector
 
-serializeIndexerToFile :: Serialize entity => FilePath -> Indexer entity -> IO (Either IOException ())
-serializeIndexerToFile path indexer = do
-  entityTable <- createIndexerEntityTable indexer
-  let
-    produce = PotokiProduce.put (Cereal.put entityTable)
-    consume = PotokiConsume.writeBytesToFile path
-    in PotokiIo.produceAndConsume produce consume
+serializeEntityTableToFile :: Serialize entity => EntityTable entity -> FilePath -> IO (Either IOException ())
+serializeEntityTableToFile entityTable path = let
+  produce = PotokiProduce.put (Cereal.put entityTable)
+  consume = PotokiConsume.writeBytesToFile path
+  in PotokiIo.produceAndConsume produce consume
 
-indexProduceToFiles :: (Eq entity, Hashable entity, Serialize entity) => FilePath {-^ Entity table -} -> FilePath {-^ Index stream -} -> Produce entity -> IO (Either IOException ())
-indexProduceToFiles entityTablePath indexStreamPath entityProduce =
-  do
-    indexer <- createIndexer
-    runExceptT $ do
-      ExceptT (serializeProduceEntityIndicesToFile indexStreamPath indexer entityProduce)
-      ExceptT (serializeIndexerToFile entityTablePath indexer)
+serializeIndexerToFile :: Serialize a => (Text -> IO ()) -> FilePath -> Indexer a -> IO (Either IOException ())
+serializeIndexerToFile log file indexer = do
+  log "Freezing"
+  entityTable <- freezeIndexerAsEntityTable indexer
+  log "Writing to file"
+  serializeEntityTableToFile entityTable file
 
 readEntitiesAmountFromEntityTableFile :: FilePath -> IO (Either IOException Int)
 readEntitiesAmountFromEntityTableFile filePath =
@@ -71,12 +68,6 @@
 
 readEntityTableFromFile :: Serialize entity => FilePath -> IO (Either IOException (Either Text (EntityTable entity)))
 readEntityTableFromFile filePath =
-  PotokiIo.produceAndConsume
-    (PotokiProduce.fileBytes filePath)
-    (right' (PotokiConsume.get Cereal.get))
-
-readIndexTableFromFile :: (Serialize entity, Eq entity, Hashable entity) => FilePath -> IO (Either IOException (Either Text (IndexTable entity)))
-readIndexTableFromFile filePath =
   PotokiIo.produceAndConsume
     (PotokiProduce.fileBytes filePath)
     (right' (PotokiConsume.get Cereal.get))
diff --git a/library/Indexation/Index.hs b/library/Indexation/Index.hs
deleted file mode 100644
--- a/library/Indexation/Index.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module Indexation.Index
-(
-  Index(..),
-)
-where
-
-import Indexation.Prelude
-import Indexation.Types
-import Indexation.Instances.Cereal ()
diff --git a/library/Indexation/IndexTable.hs b/library/Indexation/IndexTable.hs
deleted file mode 100644
--- a/library/Indexation/IndexTable.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-module Indexation.IndexTable
-(
-  IndexTable,
-  lookup,
-  register,
-  empty,
-)
-where
-
-import Indexation.Prelude hiding (lookup, empty)
-import Indexation.Types
-import Indexation.Instances.Cereal ()
-import qualified Data.HashMap.Strict as A
-
-
-lookup :: (Eq entity, Hashable entity) => entity -> IndexTable entity -> Maybe (Index entity)
-lookup entity (IndexTable size hashMap) =
-  fmap Index (A.lookup entity hashMap)
-
-register :: (Eq entity, Hashable entity) => entity -> IndexTable entity -> (Index entity, IndexTable entity)
-register entity (IndexTable size hashMap) =
-  A.lookup entity hashMap & \ case
-    Just index -> (Index index, IndexTable size hashMap)
-    Nothing -> let
-      newSize = succ size
-      newHashMap = A.insert entity size hashMap
-      index = Index size
-      newTable = IndexTable newSize newHashMap
-      in (index, newTable)
-
-empty :: (Eq entity, Hashable entity) => IndexTable entity
-empty =
-  IndexTable 0 mempty
diff --git a/library/Indexation/Instances.hs b/library/Indexation/Instances.hs
new file mode 100644
--- /dev/null
+++ b/library/Indexation/Instances.hs
@@ -0,0 +1,12 @@
+module Indexation.Instances
+where
+
+import Indexation.Prelude
+import Indexation.Types
+import Indexation.Instances.Cereal ()
+
+
+deriving instance Show (Index a)
+deriving instance Eq (Index a)
+deriving instance Ord (Index a)
+deriving instance Hashable (Index a)
diff --git a/library/Indexation/Potoki/Produce.hs b/library/Indexation/Potoki/Produce.hs
deleted file mode 100644
--- a/library/Indexation/Potoki/Produce.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-module Indexation.Potoki.Produce where
-
-import Indexation.Prelude
-import Indexation.Types
-import Indexation.Instances.Cereal ()
-import Potoki.Produce
-import Potoki.Cereal.Produce
-
-
-indicesFromFile :: FilePath -> Produce (Either IOException (Either Text (Index a)))
-indicesFromFile path =
-  fileDecoded path
diff --git a/library/Indexation/Potoki/Transform.hs b/library/Indexation/Potoki/Transform.hs
--- a/library/Indexation/Potoki/Transform.hs
+++ b/library/Indexation/Potoki/Transform.hs
@@ -1,14 +1,25 @@
-module Indexation.Potoki.Transform where
+module Indexation.Potoki.Transform
+(
+  Transform,
+  Index(..),
+  Indexer,
+  EntityTable,
+  index,
+  lookup,
+)
+where
 
-import Indexation.Prelude hiding (runState)
+import Indexation.Prelude hiding (runState, index, lookup)
 import Indexation.Types
+import Indexation.Instances ()
 import Potoki.Transform
 import qualified Focus
 import qualified StmContainers.Map as StmMap
+import qualified Data.Vector as Vector
 
 
-indexConcurrently :: (Eq entity, Hashable entity) => Indexer entity -> Transform entity (Index entity)
-indexConcurrently (Indexer sizeVar map) =
+index :: (Eq entity, Hashable entity) => Indexer entity -> Transform entity (Index entity)
+index (Indexer sizeVar map) =
   mapInIO $ \ entity -> atomically $ StmMap.focus focus entity map
   where
     focus = Focus.Focus conceal reveal where
@@ -17,3 +28,9 @@
         writeTVar sizeVar $! succ size
         return (Index size, Focus.Set size)
       reveal indexInt = return (Index indexInt, Focus.Leave)
+
+lookup :: EntityTable entity -> Transform (Index entity) (Maybe entity)
+lookup (EntityTable entityTableVector) =
+  arr $ \ (Index indexInt) -> if Vector.length entityTableVector > indexInt
+    then Just $! Vector.unsafeIndex entityTableVector indexInt
+    else Nothing
diff --git a/library/Indexation/Prelude.hs b/library/Indexation/Prelude.hs
--- a/library/Indexation/Prelude.hs
+++ b/library/Indexation/Prelude.hs
@@ -85,10 +85,6 @@
 import DeferredFolds.Unfold as Exports (Unfold(..))
 import DeferredFolds.UnfoldM as Exports (UnfoldM(..))
 
--- foldl
--------------------------
-import Control.Foldl as Exports (Fold(..), FoldM(..))
-
 -- hashable
 -------------------------
 import Data.Hashable as Exports (Hashable(..))
diff --git a/library/Indexation/Types.hs b/library/Indexation/Types.hs
--- a/library/Indexation/Types.hs
+++ b/library/Indexation/Types.hs
@@ -5,7 +5,7 @@
 import qualified StmContainers.Map as A
 
 
-data Indexer entity = Indexer (TVar Int) (A.Map entity Int)
+data Indexer entity = Indexer {-# UNPACK #-} !(TVar Int) {-# UNPACK #-} !(A.Map entity Int)
 
 data IndexTable entity = IndexTable {-# UNPACK #-} !Int {-# UNPACK #-} !(HashMap entity Int)
 
