diff --git a/Crypto/Pbkdf2.hs b/Crypto/Pbkdf2.hs
--- a/Crypto/Pbkdf2.hs
+++ b/Crypto/Pbkdf2.hs
@@ -18,6 +18,18 @@
   | B.length x == B.length y = B.pack $ B.zipWith xor x y
   | otherwise = error "xor bytestrings are not of equal length"
 
+pbkdf2_internal createBlocks prf password salt iterations = B.concat $ createBlocks $ first_iteration . hash'
+  where
+    hash' = prf password
+    first_iteration hash = additional_iterations hash hash 1
+    additional_iterations prev_hash prev_result i
+      | i == iterations = prev_result
+      | i > iterations = error "Count must be at least 1"
+      | otherwise = additional_iterations current_hash result (i + 1)
+        where
+          current_hash = (hash' prev_hash)
+          result = xorByteStrings current_hash prev_result
+
 -- | This is a non standard variation of PBKDF2 which recursively uses the
 -- last generated value to improve the salt. In difference to pbkdf2 the
 -- salt can not be precalculated for every iteration (with a simple append
@@ -26,8 +38,8 @@
 -- calculating everything before it.  Compared to the standard this
 -- function only changes the salt for the initial PBKDF2 value of each
 -- iteration to include a salt iterated from earlier parts of the PBKDF2
--- stream. This can be verified by removing the i from (hash' $ B.concat
--- [i, salt, B.pack $ octetsBE c]).
+-- stream. This can be verified by removing the i from (hash $ B.concat [i,
+-- salt, B.pack $ octetsBE c]).
 --
 -- The added salt for the first iteration will be "", and all following
 -- will be calculated as (PRF output input), where output is the output of
@@ -42,19 +54,11 @@
                  -> B.ByteString -- ^ @Salt@, the not neccesarily secret data to use in the PBKDF2 computations.
                  -> Integer -- ^ @c@, number of iterations for the the PBKDF2 computations.
                  -> B.ByteString -- ^ @DK@, the output data in the format of an unlimited lazy ByteString.
-pbkdf2_iterative prf password salt iterations = B.concat $ pbkdf2' (B.pack []) 1
+pbkdf2_iterative prf password salt iterations = pbkdf2_internal (createBlocks (B.pack []) 1) prf password salt iterations
   where
-    hash' = prf password
-    pbkdf2' :: B.ByteString -> Bin.Word32 -> [B.ByteString]
-    pbkdf2' i c = let prev = (pbkdf2'' (hash' $ B.concat [i, salt, B.pack $ octetsBE c])) in prev:(pbkdf2' (prf prev i) (c + 1))
-    pbkdf2'' hash = pbkdf2''' hash hash 1
-    pbkdf2''' prev_hash prev_result i
-      | i == iterations = prev_result
-      | i > iterations = error "Count must be at least 1"
-      | otherwise = pbkdf2''' current_hash result (i + 1)
-        where
-          current_hash = (hash' prev_hash)
-          result = xorByteStrings current_hash prev_result
+    createBlocks :: B.ByteString -> Bin.Word32 -> (B.ByteString -> B.ByteString) -> [B.ByteString]
+    createBlocks blockSalt i hash = let prev = (hash $ B.concat [blockSalt, salt, B.pack $ octetsBE i])
+                                     in prev:(createBlocks (prf prev blockSalt) (i + 1) hash)
 
 pbkdf2 :: (B.ByteString -> B.ByteString -> B.ByteString)
            -- ^ @PRF@, the PRF function to be used for PBKDF2. The first
@@ -63,17 +67,8 @@
        -> B.ByteString -- ^ @Salt@, the not neccesarily secret data to use in the PBKDF2 computations.
        -> Integer -- ^ @c@, number of iterations for the the PBKDF2 computations.
        -> B.ByteString -- ^ @DK@, the output data in the format of an unlimited lazy ByteString.
-pbkdf2 prf password salt iterations = B.concat $ pbkdf2' 1 True
+pbkdf2 prf password salt iterations = pbkdf2_internal (createBlocks True 1) prf password salt iterations
   where
-    hash' = prf password
-    pbkdf2' :: Bin.Word32 -> Bool -> [B.ByteString]
-    pbkdf2' 1 False = error "Hashing algorithm looped, stopping to maintain security of data" -- Paranoia, but that's useful when doing crypto
-    pbkdf2' i _ = (pbkdf2'' (hash' $ B.concat [salt, B.pack $ octetsBE i])):(pbkdf2' (i + 1) False)
-    pbkdf2'' hash = pbkdf2''' hash hash 1
-    pbkdf2''' prev_hash prev_result i
-      | i == iterations = prev_result
-      | i > iterations = error "Count must be at least 1"
-      | otherwise = pbkdf2''' current_hash result (i + 1)
-        where
-          current_hash = (hash' prev_hash)
-          result = xorByteStrings current_hash prev_result
+    createBlocks :: Bool -> Bin.Word32 -> (B.ByteString -> B.ByteString) -> [B.ByteString]
+    createBlocks False 1 _ = error "Hashing algorithm looped, stopping to maintain security of data" -- Paranoia, but that's useful when doing crypto
+    createBlocks _ i hash = (hash $ B.concat [salt, B.pack $ octetsBE i]):(createBlocks False (i + 1) hash)
diff --git a/Lazy-Pbkdf2.cabal b/Lazy-Pbkdf2.cabal
--- a/Lazy-Pbkdf2.cabal
+++ b/Lazy-Pbkdf2.cabal
@@ -1,5 +1,5 @@
 Name:           Lazy-Pbkdf2
-Version:        2.1.0
+Version:        2.1.1
 Author:         Marcus Ofenhed <marcus@conditionraise.se>
 Maintainer:     Marcus Ofenhed <marcus@conditionraise.se>
 License:        MIT
