diff --git a/Data/Array/Repa/Algorithms/Convolve.hs b/Data/Array/Repa/Algorithms/Convolve.hs
--- a/Data/Array/Repa/Algorithms/Convolve.hs
+++ b/Data/Array/Repa/Algorithms/Convolve.hs
@@ -4,8 +4,8 @@
 -- | Generic stencil based convolutions. 
 -- 
 --   If your stencil fits within a 7x7 tile and is known at compile-time then using
---   then using the built-in stencil support provided by the main Repa package will
---   be 5-10x faster. 
+--   the built-in stencil support provided by the main Repa package will be
+--   5-10x faster. 
 -- 
 --   If you have a larger stencil, the coefficients are not statically known, 
 --   or need more complex boundary handling than provided by the built-in functions,
diff --git a/Data/Array/Repa/Algorithms/Matrix.hs b/Data/Array/Repa/Algorithms/Matrix.hs
--- a/Data/Array/Repa/Algorithms/Matrix.hs
+++ b/Data/Array/Repa/Algorithms/Matrix.hs
@@ -2,10 +2,10 @@
 {-# LANGUAGE PackageImports #-}
 
 -- | Algorithms operating on matrices.
--- 
+--
 --   These functions should give performance comparable with nested loop C
---   implementations. 
--- 
+--   implementations.
+--
 --   If you care deeply about runtime performance then you
 --   may be better off using a binding to LAPACK, such as hvector.
 --
@@ -27,7 +27,6 @@
 import Data.Array.Repa                  as R
 import Data.Array.Repa.Eval             as R
 import Data.Array.Repa.Unsafe           as R
-import Control.Monad
 import Control.Monad.ST.Strict
 
 
@@ -47,18 +46,18 @@
 -- MMult ----------------------------------------------------------------------
 -- | Matrix matrix multiply, in parallel.
 mmultP  :: Monad m
-        => Array U DIM2 Double 
-        -> Array U DIM2 Double 
+        => Array U DIM2 Double
+        -> Array U DIM2 Double
         -> m (Array U DIM2 Double)
 
-mmultP arr brr 
- = [arr, brr] `deepSeqArrays` 
+mmultP arr brr
+ = [arr, brr] `deepSeqArrays`
    do   trr      <- transpose2P brr
         let (Z :. h1  :. _)  = extent arr
         let (Z :. _   :. w2) = extent brr
-        trr `deepSeqArray` computeP 
+        trr `deepSeqArray` computeP
          $ fromFunction (Z :. h1 :. w2)
-         $ \ix   -> R.sumAllS 
+         $ \ix   -> R.sumAllS
                   $ R.zipWith (*)
                         (unsafeSlice arr (Any :. (row ix) :. All))
                         (unsafeSlice trr (Any :. (col ix) :. All))
@@ -66,18 +65,18 @@
 
 
 -- | Matrix matrix multiply, sequentially.
-mmultS  :: Array U DIM2 Double 
-        -> Array U DIM2 Double 
+mmultS  :: Array U DIM2 Double
         -> Array U DIM2 Double
+        -> Array U DIM2 Double
 
 mmultS arr brr
  = [arr, brr]  `deepSeqArrays` (runST $
    do   trr     <- R.now $ transpose2S brr
         let (Z :. h1  :. _)  = extent arr
         let (Z :. _   :. w2) = extent brr
-        return $ computeS 
+        return $ computeS
          $ fromFunction (Z :. h1 :. w2)
-         $ \ix   -> R.sumAllS 
+         $ \ix   -> R.sumAllS
                   $ R.zipWith (*)
                         (unsafeSlice arr (Any :. (row ix) :. All))
                         (unsafeSlice trr (Any :. (col ix) :. All)))
@@ -87,13 +86,13 @@
 -- Transpose ------------------------------------------------------------------
 -- | Transpose a 2D matrix, in parallel.
 transpose2P
-        :: Monad m 
-        => Array U DIM2 Double 
+        :: Monad m
+        => Array U DIM2 Double
         -> m (Array U DIM2 Double)
 
 transpose2P arr
  = arr `deepSeqArray`
-   do   computeUnboxedP 
+   do   computeUnboxedP
          $ unsafeBackpermute new_extent swap arr
  where  swap (Z :. i :. j)      = Z :. j :. i
         new_extent              = swap (extent arr)
@@ -102,7 +101,7 @@
 
 -- | Transpose a 2D matrix, sequentially.
 transpose2S
-        :: Array U DIM2 Double 
+        :: Array U DIM2 Double
         -> Array U DIM2 Double
 
 transpose2S arr
@@ -117,25 +116,15 @@
 -- Trace ------------------------------------------------------------------------
 -- | Get the trace of a (square) 2D matrix, in parallel.
 trace2P :: Monad m => Array U DIM2 Double -> m Double
-trace2P x 
- = liftM (safeHead . toList) $ sumP $ slice y (Z :. (0 :: Int) :. All)
+trace2P x
+ = sumAllP $ unsafeBackpermute (Z :. (min nRows nColumns)) (\(Z :. i) -> (Z :. i :. i)) x
  where
-    safeHead []     = error "repa-algorithms: trace2P empty list"
-    safeHead (x':_) = x'
-
-    y               = unsafeBackpermute (extent x) f x
-    f (Z :. i :. j) = Z :. (i - j) `mod` nRows:. j
-    Z :. nRows :. _nCols = extent x
+    (Z :. nRows :. nColumns) = extent x
 
 
 -- | Get the trace of a (square) 2D matrix, sequentially.
 trace2S :: Array U DIM2 Double -> Double
-trace2S x 
- = safeHead $ toList $ sumS $ slice y (Z :. (0 :: Int) :. All)
+trace2S x
+ = sumAllS $ unsafeBackpermute (Z :. (min nRows nColumns)) (\(Z :. i) -> (Z :. i :. i)) x
  where
-    safeHead []     = error "repa-algorithms: trace2S empty list"
-    safeHead (x':_) = x'
-
-    y               =  unsafeBackpermute (extent x) f x
-    f (Z :. i :. j) = Z :. (i - j) `mod` nRows:. j
-    Z :. nRows :. _nCols = extent x
+    (Z :. nRows :. nColumns) = extent x
diff --git a/repa-algorithms.cabal b/repa-algorithms.cabal
--- a/repa-algorithms.cabal
+++ b/repa-algorithms.cabal
@@ -1,11 +1,11 @@
 Name:                repa-algorithms
-Version:             3.4.1.3
+Version:             3.4.1.4
 License:             BSD3
 License-file:        LICENSE
 Author:              The DPH Team
 Maintainer:          Ben Lippmeier <benl@ouroborus.net>
 Build-Type:          Simple
-Cabal-Version:       >=1.6
+Cabal-Version:       >=1.10
 Stability:           experimental
 Category:            Data Structures
 Homepage:            http://repa.ouroborus.net
@@ -18,7 +18,7 @@
 
 Library
   Build-Depends:
-        base                 >= 4.8 && < 4.13
+        base                 >= 4.8 && < 4.15
       , vector               >= 0.11 && < 0.13
       , repa                 == 3.4.1.*
 
@@ -38,7 +38,10 @@
   else
     ghc-options: -fcpr-off
 
-  extensions:
+  default-language:
+        Haskell2010
+
+  default-extensions:
         NoMonomorphismRestriction
         ExplicitForAll
         EmptyDataDecls
