diff --git a/Numeric/SGD.hs b/Numeric/SGD.hs
--- a/Numeric/SGD.hs
+++ b/Numeric/SGD.hs
@@ -114,7 +114,7 @@
         frozen <- U.unsafeFreeze x
         notify frozen k
 
-        -- let grad = M.unionsWith (<+>) (map (mkGrad frozen) batch)
+        -- let grad = M.unions (map (mkGrad frozen) batch)
         let grad = parUnions (map (mkGrad frozen) batch)
         addUp grad u
         scale (gain k) u
diff --git a/Numeric/SGD/Grad.hs b/Numeric/SGD/Grad.hs
--- a/Numeric/SGD/Grad.hs
+++ b/Numeric/SGD/Grad.hs
@@ -24,12 +24,15 @@
 ) where
 
 import Data.List (foldl')
-import qualified Data.IntMap as M
-#if MIN_VERSION_containers(0,4,2)
 import Control.Applicative ((<$>), (<*>))
-import Control.Monad.Par.Scheds.Direct (Par, runPar, spawn, get)
+import Control.Monad.Par.Scheds.Direct (Par, runPar, get)
+#if MIN_VERSION_containers(0,4,2)
+import Control.Monad.Par.Scheds.Direct (spawn)
 #else
+import Control.DeepSeq (deepseq)
+import Control.Monad.Par.Scheds.Direct (spawn_)
 #endif
+import qualified Data.IntMap as M
 
 import Numeric.SGD.LogSigned
 
@@ -44,11 +47,19 @@
 #if MIN_VERSION_containers(0,4,1)
 insertWith = M.insertWith'
 #else
-insertWith f k x m = case M.lookup k m of
-    Just y  ->
-        let x' = f x y
-        in  x' `seq` M.insert k x' m
-    Nothing -> x `seq` M.insert k x m
+insertWith f k x m = 
+    M.alter g k m
+  where
+    g my = case my of
+        Nothing -> Just x
+        Just y  ->
+            let z = f x y
+            in  z `seq` Just z
+-- insertWith f k x m = case M.lookup k m of
+--     Just y  ->
+--         let x' = f x y
+--         in  x' `seq` M.insert k x' m
+--     Nothing -> x `seq` M.insert k x m
 #endif
 
 -- | Add normal-domain double to the gradient at the given position.
@@ -96,23 +107,26 @@
 -- Experimental version.
 parUnions :: [Grad] -> Grad
 parUnions [] = error "parUnions: empty list"
-#if MIN_VERSION_containers(0,4,2)
 parUnions xs = runPar (parUnionsP xs)
 
--- | Parallel unoins in the Par monad.
+-- | Parallel unions in the Par monad.
 parUnionsP :: [Grad] -> Par Grad
 parUnionsP [x] = return x
 parUnionsP zs  = do
     let (xs, ys) = split zs
+#if MIN_VERSION_containers(0,4,2)
     xsP <- spawn (parUnionsP xs)
     ysP <- spawn (parUnionsP ys)
     M.unionWith (+) <$> get xsP <*> get ysP
+#else
+    xsP <- spawn_ (parUnionsP xs)
+    ysP <- spawn_ (parUnionsP ys)
+    x <- M.unionWith (+) <$> get xsP <*> get ysP
+    M.elems x `deepseq` return x
+#endif
   where
     split []        = ([], [])
     split (x:[])    = ([x], [])
     split (x:y:rest)  =
         let (xs, ys) = split rest
         in  (x:xs, y:ys)
-#else
-parUnions xs = M.unions xs
-#endif
diff --git a/sgd.cabal b/sgd.cabal
--- a/sgd.cabal
+++ b/sgd.cabal
@@ -1,5 +1,5 @@
 name:               sgd
-version:            0.2.1
+version:            0.2.2
 synopsis:           Stochastic gradient descent
 description:
     Implementation of a Stochastic Gradient Descent optimization method.
