diff --git a/Data/AhoCorasick.hs b/Data/AhoCorasick.hs
--- a/Data/AhoCorasick.hs
+++ b/Data/AhoCorasick.hs
@@ -93,11 +93,11 @@
 buildOutput :: (Eq a, Hashable a) => [([a], v)] -> GotoMap a -> FailureMap -> OutputMap v
 buildOutput pvs gotoMap failureMap = foldl' build o0 $ tail $ toBFList gotoMap
   where
-    build o s = foldl' (\a (_, s') -> Map.insertWith (flip (++)) s' (lookupDefault [] (failure s') a) a) o ts
+    build o s = foldl' (\a (_, s') -> let vs = lookupDefault [] (failure s') a in vs `seq` Map.insertWith (flip (++)) s' vs a) o ts
       where
         ts = Map.toList $ lookupDefault Map.empty s gotoMap
     failure = fromMaybe (error "failure: ") . flip Map.lookup failureMap
-    o0 = Map.fromList $ fromJust $ mapM toKV pvs
+    o0 = Map.fromList $ map (fromJust . toKV) pvs
     toKV (p, v) = do
         s <- finalState gotoMap root p
         return (s, [(length p, v)])
diff --git a/ac-machine.cabal b/ac-machine.cabal
--- a/ac-machine.cabal
+++ b/ac-machine.cabal
@@ -1,5 +1,5 @@
 name:                ac-machine
-version:             0.2.0.1
+version:             0.2.0.2
 synopsis:            Aho-Corasick string matching algorithm in Haskell
 description:         An implementation of the Aho-Corasick string matching algorithm written in Haskell.
 license:             BSD3
