diff --git a/Crypto/Threefish/Skein/StreamCipher.hs b/Crypto/Threefish/Skein/StreamCipher.hs
--- a/Crypto/Threefish/Skein/StreamCipher.hs
+++ b/Crypto/Threefish/Skein/StreamCipher.hs
@@ -32,14 +32,13 @@
 
 stream256 :: Skein256Ctx -> [BS.ByteString]
 stream256 (Skein256Ctx c) =
-    unsafePerformIO $ go 0
+    unsafePerformIO $ withForeignPtr c $ go 0
   where
-    go n = unsafeInterleaveIO $ do
-      bs <- withForeignPtr c $ \ctx -> do
-        allocaBytes 1024 $ \ptr -> do
-          skein256_output ctx n (n+32) ptr
-          BS.packCStringLen (castPtr ptr, 1024)
-      bss <- go (n+32)
+    go n ctx = unsafeInterleaveIO $ do
+      bs <- allocaBytes 1024 $ \ptr -> do
+        skein256_output ctx n (n+32) ptr
+        BS.packCStringLen (castPtr ptr, 1024)
+      bss <- go (n+32) ctx
       return $ bs : bss
 
 keystream256 :: Key256 -> Nonce256 -> [BS.ByteString]
diff --git a/threefish.cabal b/threefish.cabal
--- a/threefish.cabal
+++ b/threefish.cabal
@@ -1,5 +1,5 @@
 name:                threefish
-version:             0.2.4
+version:             0.2.5
 synopsis:            The Threefish block cipher and the Skein hash function for Haskell.
 description:         Implements 256 and 512 bit variants of Threefish and Skein. Skein is usable as a "normal" hash function as well as in Skein-MAC, as a cryptographically secure PRNG, as a stream cipher and as a key derivation function, all implemented according to the specifications of the Skein 1.3 paper.
 homepage:            http://github.com/valderman/threefish
