diff --git a/flat-mcmc.cabal b/flat-mcmc.cabal
--- a/flat-mcmc.cabal
+++ b/flat-mcmc.cabal
@@ -1,5 +1,5 @@
 name:                flat-mcmc
-version:             1.4.0
+version:             1.4.1
 synopsis:            Painless general-purpose sampling.
 homepage:            https://github.com/jtobin/flat-mcmc
 license:             MIT
diff --git a/lib/Numeric/MCMC/Flat.hs b/lib/Numeric/MCMC/Flat.hs
--- a/lib/Numeric/MCMC/Flat.hs
+++ b/lib/Numeric/MCMC/Flat.hs
@@ -141,7 +141,7 @@
   zcs <- replicateM n uniform
   js  <- U.replicateM n (uniformR (1, n))
 
-  let granularity = truncate (fromIntegral n / 2)
+  let granularity = n `div` 2
 
       w0 k    = e0 `V.unsafeIndex` pred k
       w1 k ks = e1 `V.unsafeIndex` pred (ks `U.unsafeIndex` pred k)
diff --git a/src/Main.hs b/src/Main.hs
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -3,11 +3,12 @@
 module Main where
 
 import Numeric.MCMC.Flat
-import qualified Data.Vector.Unboxed as U (toList)
+import qualified Data.Vector.Unboxed as U (unsafeIndex)
 
 bnn :: Particle -> Double
 bnn xs = -0.5 * (x0 ^ 2 * x1 ^ 2 + x0 ^ 2 + x1 ^ 2 - 8 * x0 - 8 * x1) where
-  [x0, x1] = U.toList xs
+  x0 = U.unsafeIndex xs 0
+  x1 = U.unsafeIndex xs 1
 
 origin :: Ensemble
 origin = ensemble [
diff --git a/test/BNN.hs b/test/BNN.hs
--- a/test/BNN.hs
+++ b/test/BNN.hs
@@ -3,11 +3,12 @@
 module Main where
 
 import Numeric.MCMC.Flat
-import qualified Data.Vector.Unboxed as U (toList)
+import qualified Data.Vector.Unboxed as U (unsafeIndex)
 
 bnn :: Particle -> Double
 bnn xs = -0.5 * (x0 ^ 2 * x1 ^ 2 + x0 ^ 2 + x1 ^ 2 - 8 * x0 - 8 * x1) where
-  [x0, x1] = U.toList xs
+  x0 = U.unsafeIndex xs 0
+  x1 = U.unsafeIndex xs 1
 
 origin :: Ensemble
 origin = ensemble [
diff --git a/test/Rosenbrock.hs b/test/Rosenbrock.hs
--- a/test/Rosenbrock.hs
+++ b/test/Rosenbrock.hs
@@ -3,11 +3,12 @@
 module Main where
 
 import Numeric.MCMC.Flat
-import qualified Data.Vector.Unboxed as U (toList)
+import qualified Data.Vector.Unboxed as U (unsafeIndex)
 
 rosenbrock :: Particle -> Double
 rosenbrock xs = negate (5  *(x1 - x0 ^ 2) ^ 2 + 0.05 * (1 - x0) ^ 2) where
-  [x0, x1] = U.toList xs
+  x0 = U.unsafeIndex xs 0
+  x1 = U.unsafeIndex xs 1
 
 origin :: Ensemble
 origin = ensemble [
