 data KnotState = KnotState { valueMap :: Map IntPtr Value
                            , typeMap :: Map IntPtr Type
                            , idSrc :: IORef Int
+                           , typeIdSrc :: IORef Int
                            , result :: Maybe Module
                            , visitedTypes :: Set IntPtr
                            , localId :: Int
                            , constantTranslationDepth :: Int
                            }
-emptyState :: IORef Int -> KnotState
-emptyState r = KnotState { valueMap = M.empty
+emptyState :: IORef Int -> IORef Int -> KnotState
+emptyState r1 r2 = KnotState { valueMap = M.empty
                          , typeMap = M.empty
-                         , idSrc = r
+                         , idSrc = r1
+                         , typeIdSrc = r2
                          , result = Nothing
                          , visitedTypes = S.empty
                          , localId = 0

  liftIO $ modifyIORef r (+1)

  return thisId

-- | Parse the named LLVM bitcode file into the LLVM form of the IR (a
-- 'Module').  In the case of an error, a descriptive string will be

    exHandler :: TranslationException -> IO (Either String Module)
    exHandler ex = return $ Left (show ex)
    doParse m = do
      idref <- newIORef 0
      tref <- newIORef 0
      res <- evalStateT (mfix (tieKnot m)) (emptyState idref tref)

      disposeCModule m
      case result res of
