diff --git a/Crypto/Cipher/AES.hs b/Crypto/Cipher/AES.hs
--- a/Crypto/Cipher/AES.hs
+++ b/Crypto/Cipher/AES.hs
@@ -284,11 +284,13 @@
     | len <= 0  = (B.empty, iv)
     | otherwise = unsafePerformIO $ do
         fptr  <- B.mallocByteString outputLength
-        newIv <- withForeignPtr fptr generate
+        newIv <- withForeignPtr fptr $ \o ->
+                    keyToPtr ctx $ \k ->
+                    ivCopyPtr iv $ \i -> do
+                        c_aes_gen_ctr_cont (castPtr o) k i (fromIntegral nbBlocks)
         let !out = B.PS fptr 0 outputLength
         return $! (out `seq` newIv `seq` (out, newIv))
-  where generate o = keyToPtr ctx $ \k -> ivCopyPtr iv $ \i ->
-            c_aes_gen_ctr_cont (castPtr o) k i (fromIntegral nbBlocks)
+  where
         (nbBlocks',r) = len `quotRem` 16
         nbBlocks = if r == 0 then nbBlocks' else nbBlocks' + 1
         outputLength = nbBlocks * 16
@@ -615,7 +617,7 @@
 foreign import ccall "aes.h aes_gen_ctr"
     c_aes_gen_ctr :: CString -> Ptr AES -> Ptr Word8 -> CUInt -> IO ()
 
-foreign import ccall "aes.h aes_gen_ctr_cont"
+foreign import ccall unsafe "aes.h aes_gen_ctr_cont"
     c_aes_gen_ctr_cont :: CString -> Ptr AES -> Ptr Word8 -> CUInt -> IO ()
 
 foreign import ccall "aes.h aes_encrypt_ctr"
diff --git a/cbits/aes.c b/cbits/aes.c
--- a/cbits/aes.c
+++ b/cbits/aes.c
@@ -169,7 +169,7 @@
 #define aes_decrypt_block(o,k,i) \
 	(((block_f) (branch_table[DECRYPT_BLOCK_128 + k->strength]))(o,k,i))
 #else
-#define GET_INIT(strenght) aes_generic_init
+#define GET_INIT(strength) aes_generic_init
 #define GET_ECB_ENCRYPT(strength) aes_generic_encrypt_ecb
 #define GET_ECB_DECRYPT(strength) aes_generic_decrypt_ecb
 #define GET_CBC_ENCRYPT(strength) aes_generic_encrypt_cbc
diff --git a/cipher-aes.cabal b/cipher-aes.cabal
--- a/cipher-aes.cabal
+++ b/cipher-aes.cabal
@@ -1,5 +1,5 @@
 Name:                cipher-aes
-Version:             0.2.9
+Version:             0.2.10
 Description:
     Fast AES cipher implementation with advanced mode of operations.
     .
@@ -24,7 +24,7 @@
 Synopsis:            Fast AES cipher implementation with advanced mode of operations
 Category:            Cryptography
 Build-Type:          Simple
-Homepage:            http://github.com/vincenthz/hs-cipher-aes
+Homepage:            https://github.com/vincenthz/hs-cipher-aes
 Cabal-Version:       >=1.8
 Extra-Source-Files:  Tests/*.hs
                      cbits/*.h
@@ -78,4 +78,4 @@
 
 source-repository head
   type:     git
-  location: git://github.com/vincenthz/hs-cipher-aes
+  location: https://github.com/vincenthz/hs-cipher-aes
