diff --git a/Data/Vec/Base.hs b/Data/Vec/Base.hs
--- a/Data/Vec/Base.hs
+++ b/Data/Vec/Base.hs
@@ -365,7 +365,7 @@
 
 
 -- | @snoc v a@ appends the element a to the end of v. 
-class Snoc v a v' | v a -> v', v' -> v a, v -> a where 
+class Snoc v a v' | v a -> v', v' -> v a where 
   snoc :: v -> a -> v'
 
 instance Snoc () a (a:.()) where
diff --git a/Data/Vec/LinAlg.hs b/Data/Vec/LinAlg.hs
--- a/Data/Vec/LinAlg.hs
+++ b/Data/Vec/LinAlg.hs
@@ -55,9 +55,6 @@
 import Control.Monad
 import Data.Maybe
 
-import Unsafe.Coerce
-
-
 -- | dot \/ inner \/ scalar product
 dot ::  (Num a, Num v, Fold v a) => v -> v -> a
 dot u v = sum (u*v)
@@ -628,8 +625,10 @@
   -- row echelon form. Returns @Nothing@ if the matrix is rank deficient. 
   backSubstitute :: m -> Maybe m 
 
-instance BackSubstitute ((a:.r):.()) where
-  backSubstitute = Just . id
+instance NearZero a => BackSubstitute ((a:.r):.()) where
+  backSubstitute r@((a:._):._) 
+    | nearZero (1-a) = Just r
+    | otherwise = Nothing
   {-# INLINE backSubstitute #-}
 
 instance 
@@ -643,11 +642,11 @@
     , BackSubstitute rs_
     ) => BackSubstitute ((a:.r):.(a:.r):.rs)
   where
-    backSubstitute (r@(rh:.rt):.rs) 
+    backSubstitute m@(r@(rh:.rt):.rs) 
       | nearZero (1-rh) = 
-        liftM (map (0:.)) (backSubstitute . map tail $ rs) >>= \rs' -> 
-          return . (:.rs') . foldl (\v (a,w) -> sub v a w) r $ 
-            zipWith (,) rt rs'
+          liftM (map (0:.)) (backSubstitute . map tail $ rs) >>= \rs' -> 
+            return . (:.rs') . foldl (\v (a,w) -> sub v a w) r $ 
+              zipWith (,) rt rs'
       | otherwise = Nothing -- rank deficient
           where sub v a = zipWith (-) v . map (*a)
     {-# INLINE backSubstitute #-}
@@ -705,7 +704,7 @@
 
 -- | inverse and determinant. If det = 0, inverted matrix is garbage.
 invertAndDet :: forall n a r m r' m'. 
-  ( Num r, Num m
+  ( Num a, Num r, Num m
   , Vec n a r     -- r is row type
   , Vec n r m     -- m is matrix type
   , Append r r r' -- r' is a row of augmented matrix
@@ -714,12 +713,16 @@
   , Map r' r m' m -- get the right half of the augmented matrix
   , SetDiagonal r m -- needed to make identity matrix
   , GaussElim a m'
-  , BackSubstitute' m'
+  , BackSubstitute m'
   ) => m -> (m,a)
 invertAndDet m = 
-  mapFst ( (map dropn) . backSubstitute') . gaussElim . zipWith append m $ i
-  where dropn = drop (undefined::n)
-        i = identity :: m
+  case backSubstitute rref of
+    Nothing -> (m,0)
+    Just m' -> ( map dropn m' , d )
+  where 
+    (rref,d) = gaussElim . zipWith append m $ i
+    dropn = drop (undefined::n)
+    i = identity :: m
 {-# INLINE invertAndDet #-}
 
 -- | Solution of linear system by Gaussian elimination. Returns @Nothing@
diff --git a/Vec.cabal b/Vec.cabal
--- a/Vec.cabal
+++ b/Vec.cabal
@@ -1,5 +1,5 @@
 Name:                Vec
-Version:             0.9.6
+Version:             0.9.7
 License:             BSD3
 License-file:        LICENSE
 Author:              Scott E. Dillard
@@ -14,14 +14,13 @@
    provides a set of common list-like functions (map, fold, etc) for working
    with vectors. Built up from these functions are a small but useful set of
    linear algebra operations: matrix multiplication, determinants, solving
-   linear systems, inverting matrices. Efficient code is generated using
-   Storable and unboxed array instances or an optional packed representation.
+   linear systems, inverting matrices.
 Cabal-version:       >=1.2.3
 Build-type:          Simple
 Category:            Data,Math
 
 library
-    Build-Depends:      base,QuickCheck<2,array,ghc-prim
+    Build-Depends:      base<=5,QuickCheck<2,array,ghc-prim
 
     Exposed-modules:    Data.Vec 
                         Data.Vec.Base,
