diff --git a/THANKS b/THANKS
--- a/THANKS
+++ b/THANKS
@@ -77,5 +77,7 @@
 
 - Max Suica simplified the installation on Windows and improved the instructions.
 
-- John Billings reported an incompatibility with QuickCheck>=2.1.1
+- John Billings first reported an incompatibility with QuickCheck>=2.1.1
+
+- Alexey Khudyakov cleaned up PRAGMAS and fixed some hlint suggestions.
 
diff --git a/configure.hs b/configure.hs
--- a/configure.hs
+++ b/configure.hs
@@ -98,10 +98,14 @@
           cs x   = x
 
 main = do
+    info <- maybeGetPersistBuildConfig "dist"
+    case info of
+        Nothing -> putStrLn "Please run \"cabal clean\" first." >> exitFailure
+        Just bInfo -> mainOk bInfo
+        
+mainOk bInfo = do
     putStr "Checking foreign libraries..."
-
     args <- getArgs
-    Just bInfo <- maybeGetPersistBuildConfig "dist"
 
     let Just lib = library . localPkgDescr $ bInfo
         buildInfo = libBuildInfo lib
diff --git a/hmatrix.cabal b/hmatrix.cabal
--- a/hmatrix.cabal
+++ b/hmatrix.cabal
@@ -1,5 +1,5 @@
 Name:               hmatrix
-Version:            0.10.0.0
+Version:            0.10.0.1
 License:            GPL
 License-file:       LICENSE
 Author:             Alberto Ruiz
@@ -78,13 +78,16 @@
     description:    Use Data.Vector.Storable type from "vector" package.
     default:        False
 
+flag binary
+    description:    Define Binary instances
+    default:        True
+
 library
 
     Build-Depends:      base >= 4 && < 5,
                         array,
                         storable-complex,
-                        process,
-                        binary
+                        process
 
     Extensions:         ForeignFunctionInterface,
                         CPP
@@ -131,6 +134,10 @@
        Build-Depends:   vector >= 0.7
        cpp-options:     -DVECTOR
 
+    if flag(binary)
+       Build-Depends:   binary
+       cpp-options:     -DBINARY
+
     if flag(tests)
        Build-Depends:   QuickCheck, HUnit, random
        exposed-modules: Numeric.LinearAlgebra.Tests
@@ -176,3 +183,4 @@
 source-repository head
     type:     darcs
     location: http://code.haskell.org/hmatrix
+
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -1,5 +1,7 @@
-{-# OPTIONS_GHC -fglasgow-exts #-}
-{-# LANGUAGE CPP, BangPatterns #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE FlexibleContexts         #-}
+{-# LANGUAGE FlexibleInstances        #-}
+{-# LANGUAGE BangPatterns             #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Data.Packed.Internal.Matrix
@@ -158,7 +160,7 @@
 -- | extracts the rows of a matrix as a list of vectors
 toRows :: Element t => Matrix t -> [Vector t]
 toRows m = toRows' 0 where
-    v = flatten $ m
+    v = flatten m
     r = rows m
     c = cols m
     toRows' k | k == r*c  = []
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs
--- a/lib/Data/Packed/Matrix.hs
+++ b/lib/Data/Packed/Matrix.hs
@@ -2,17 +2,16 @@
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE FunctionalDependencies #-}
+{-# LANGUAGE CPP #-}
 
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Data.Packed.Matrix
 -- Copyright   :  (c) Alberto Ruiz 2007-10
--- License     :  GPL-style
+-- License     :  GPL
 --
 -- Maintainer  :  Alberto Ruiz <aruiz@um.es>
 -- Stability   :  provisional
--- Portability :  portable
 --
 -- A Matrix representation suitable for numerical computations using LAPACK and GSL.
 --
@@ -44,17 +43,15 @@
 import qualified Data.Packed.ST as ST
 import Data.List(transpose,intersperse)
 import Data.Array
+import Foreign.Storable
 
+-------------------------------------------------------------------
 
+#ifdef BINARY
+
 import Data.Binary
-import Foreign.Storable
 import Control.Monad(replicateM)
---import Control.Arrow((***))
---import GHC.Float(double2Float,float2Double)
 
-
--------------------------------------------------------------------
-
 instance (Binary a, Element a, Storable a) => Binary (Matrix a) where
     put m = do
             let r = rows m
@@ -68,6 +65,8 @@
           xs <- replicateM r $ replicateM c get
           return $ fromLists xs
 
+#endif
+
 -------------------------------------------------------------------
 
 instance (Show a, Element a) => (Show (Matrix a)) where
@@ -270,7 +269,7 @@
 -}
 buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a
 buildMatrix rc cc f =
-    fromLists $ map (\x -> map f x)
+    fromLists $ map (map f)
     	$ map (\ ri -> map (\ ci -> (ri, ci)) [0 .. (cc - 1)]) [0 .. (rc - 1)]
 
 -----------------------------------------------------
@@ -284,7 +283,7 @@
 
 -- | rearranges the rows of a matrix according to the order given in a list of integers. 
 extractRows :: Element t => [Int] -> Matrix t -> Matrix t
-extractRows l m = fromRows $ extract (toRows $ m) l
+extractRows l m = fromRows $ extract (toRows m) l
     where extract l' is = [l'!!i |i<-is]
 
 {- | creates matrix by repetition of a matrix a given number of rows and columns
diff --git a/lib/Data/Packed/Random.hs b/lib/Data/Packed/Random.hs
--- a/lib/Data/Packed/Random.hs
+++ b/lib/Data/Packed/Random.hs
@@ -63,4 +63,4 @@
     med  = konst k r `vXm` x
     meds = konst 1 r `outer` med
     xc   = x `sub` meds
-    cov  = flip scale (trans xc `mXm` xc) (recip (fromIntegral (r-1)))
+    cov  = scale (recip (fromIntegral (r-1))) (trans xc `mXm` xc)
diff --git a/lib/Data/Packed/ST.hs b/lib/Data/Packed/ST.hs
--- a/lib/Data/Packed/ST.hs
+++ b/lib/Data/Packed/ST.hs
@@ -1,5 +1,6 @@
-{-# OPTIONS -XTypeOperators -XRank2Types  -XFlexibleContexts -XBangPatterns #-}
-
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE Rank2Types    #-}
+{-# LANGUAGE BangPatterns  #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Data.Packed.ST
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs
--- a/lib/Data/Packed/Vector.hs
+++ b/lib/Data/Packed/Vector.hs
@@ -1,13 +1,13 @@
 {-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE CPP #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Data.Packed.Vector
--- Copyright   :  (c) Alberto Ruiz 2007
--- License     :  GPL-style
+-- Copyright   :  (c) Alberto Ruiz 2007-10
+-- License     :  GPL
 --
 -- Maintainer  :  Alberto Ruiz <aruiz@um.es>
 -- Stability   :  provisional
--- Portability :  portable
 --
 -- 1D arrays suitable for numeric computations using external libraries.
 --
@@ -26,12 +26,15 @@
 ) where
 
 import Data.Packed.Internal.Vector
-import Data.Binary
 import Foreign.Storable
-import Control.Monad(replicateM)
 
 -------------------------------------------------------------------
 
+#ifdef BINARY
+
+import Data.Binary
+import Control.Monad(replicateM)
+
 -- a 64K cache, with a Double taking 13 bytes in Bytestring,
 -- implies a chunk size of 5041
 chunk :: Int
@@ -59,6 +62,8 @@
           d <- get
           vs <- mapM getVector $ chunks d
           return $! join vs
+
+#endif
 
 -------------------------------------------------------------------
 
diff --git a/lib/Graphics/Plot.hs b/lib/Graphics/Plot.hs
--- a/lib/Graphics/Plot.hs
+++ b/lib/Graphics/Plot.hs
@@ -45,7 +45,7 @@
 mesh :: Matrix Double -> IO ()
 mesh m = gnuplotX (command++dat) where
     command = "splot "++datafollows++" matrix with lines\n"
-    dat = prep $ toLists $ m
+    dat = prep $ toLists m
 
 {- | Draws the surface represented by the function f in the desired ranges and number of points, internally using 'mesh'.
 
@@ -104,7 +104,7 @@
     maxgray = 255.0
     maxval = maxElement m
     minval = minElement m
-    scale' = if (maxval == minval) 
+    scale' = if maxval == minval
         then 0.0
         else maxgray / (maxval - minval)
     f x = show ( round ( scale' *(x - minval) ) :: Int )
@@ -124,7 +124,7 @@
 
 datafollows = "\\\"-\\\""
 
-prep = (++"e\n\n") . unlines . map (unwords . (map show))
+prep = (++"e\n\n") . unlines . map (unwords . map show)
 
 
 gnuplotpdf :: String -> String -> [([[Double]], String)] -> IO ()
@@ -158,7 +158,7 @@
 
        "\\end{document}"
 
-    pr = (++"e\n") . unlines . map (unwords . (map show))
+    pr = (++"e\n") . unlines . map (unwords . map show)
 
     gnuplot cmd = do
         writeFile "gnuplotcommand" cmd
@@ -172,7 +172,7 @@
     draw = concat (intersperse ", " (map ("\"-\" "++) defs)) ++ "\n" ++
            concatMap pr dats
 
-    pr = (++"e\n") . unlines . map (unwords . (map show))
+    pr = (++"e\n") . unlines . map (unwords . map show)
 
     prelude = "set title \""++title++"\";"
 
diff --git a/lib/Numeric/Chain.hs b/lib/Numeric/Chain.hs
--- a/lib/Numeric/Chain.hs
+++ b/lib/Numeric/Chain.hs
@@ -98,11 +98,11 @@
 minimum_cost sci fu = foldl (smaller_cost fu) sci (fulcrum_order fu)
 
 smaller_cost :: (Int,Int) -> (Sizes,Cost,Indexes) -> ((Int,Int),(Int,Int)) -> (Sizes,Cost,Indexes)
-smaller_cost (r,c) (mz,cost,ixes) ix@((lr,lc),(rr,rc)) = let op_cost = (fromJust ((cost A.! lr) A.! lc))
-                                                                       + (fromJust ((cost A.! rr) A.! rc))
-                                                                       + ((fst $ mz A.! (lr-lc+1))
-                                                                          *(snd $ mz A.! lc)
-                                                                          *(snd $ mz A.! rr))
+smaller_cost (r,c) (mz,cost,ixes) ix@((lr,lc),(rr,rc)) = let op_cost =   fromJust ((cost A.! lr) A.! lc)
+                                                                       + fromJust ((cost A.! rr) A.! rc)
+                                                                       + fst (mz A.! (lr-lc+1))
+                                                                         * snd (mz A.! lc)
+                                                                         * snd (mz A.! rr)
                                                              cost' = (cost A.! r) A.! c
                                                          in case cost' of
                                                                        Nothing -> let cost'' = update cost (r,c) (Just op_cost)
@@ -118,10 +118,10 @@
 fulcrum_order (r,c) = let fs' = zip (repeat r) [1..(c-1)]
                       in map (partner (r,c)) fs'
 
-partner (r,c) (a,b) = (((r-b),(c-b)),(a,b))
+partner (r,c) (a,b) = ((r-b, c-b), (a,b))
 
 order 0 = []
-order n = (order (n-1)) ++ (zip (repeat n) [1..n])
+order n = order (n-1) ++ zip (repeat n) [1..n]
 
 chain_paren :: Product a => (Int,Int) -> Indexes -> Matrices a -> Matrix a
 chain_paren (r,c) ixes ma = let ((lr,lc),(rr,rc)) = fromJust $ (ixes A.! r) A.! c
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs
--- a/lib/Numeric/Container.hs
+++ b/lib/Numeric/Container.hs
@@ -117,10 +117,10 @@
     (<>) = mXm
 
 instance Mul Matrix Vector Vector where
-    (<>) m v = flatten $ m <> (asColumn v)
+    (<>) m v = flatten $ m <> asColumn v
 
 instance Mul Vector Matrix Vector where
-    (<>) v m = flatten $ (asRow v) <> m
+    (<>) v m = flatten $ asRow v <> m
 
 --------------------------------------------------------
 
diff --git a/lib/Numeric/ContainerBoot.hs b/lib/Numeric/ContainerBoot.hs
--- a/lib/Numeric/ContainerBoot.hs
+++ b/lib/Numeric/ContainerBoot.hs
@@ -2,7 +2,6 @@
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE FunctionalDependencies #-}
 {-# LANGUAGE UndecidableInstances #-}
 
 -----------------------------------------------------------------------------
diff --git a/lib/Numeric/GSL/Fourier.hs b/lib/Numeric/GSL/Fourier.hs
--- a/lib/Numeric/GSL/Fourier.hs
+++ b/lib/Numeric/GSL/Fourier.hs
@@ -1,4 +1,4 @@
-{-# OPTIONS_GHC -fglasgow-exts #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 {- |
 Module      : Numeric.GSL.Fourier
diff --git a/lib/Numeric/GSL/Minimization.hs b/lib/Numeric/GSL/Minimization.hs
--- a/lib/Numeric/GSL/Minimization.hs
+++ b/lib/Numeric/GSL/Minimization.hs
@@ -1,4 +1,4 @@
-{-# OPTIONS_GHC -fglasgow-exts #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 {- |
 Module      :  Numeric.GSL.Minimization
diff --git a/lib/Numeric/GSL/Polynomials.hs b/lib/Numeric/GSL/Polynomials.hs
--- a/lib/Numeric/GSL/Polynomials.hs
+++ b/lib/Numeric/GSL/Polynomials.hs
@@ -1,4 +1,4 @@
-{-# OPTIONS_GHC -fglasgow-exts #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 {- |
 Module      :  Numeric.GSL.Polynomials
diff --git a/lib/Numeric/GSL/Vector.hs b/lib/Numeric/GSL/Vector.hs
--- a/lib/Numeric/GSL/Vector.hs
+++ b/lib/Numeric/GSL/Vector.hs
@@ -1,4 +1,3 @@
-{-# OPTIONS_GHC -fglasgow-exts #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Numeric.GSL.Vector
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs
--- a/lib/Numeric/LinearAlgebra/Algorithms.hs
+++ b/lib/Numeric/LinearAlgebra/Algorithms.hs
@@ -392,7 +392,7 @@
 
 -- | 1 + 0.5*peps == 1,  1 + 0.6*peps /= 1
 peps :: RealFloat x => x
-peps = x where x = 2.0**(fromIntegral $ 1-floatDigits x)
+peps = x where x = 2.0 ** fromIntegral (1 - floatDigits x)
 
 
 -- | The imaginary unit: @i = 0.0 :+ 1.0@
@@ -553,8 +553,7 @@
 geps delta = head [ k | (k,g) <- epslist, g<delta]
 
 expGolub m = iterate msq f !! j
-    where j = max 0 $ floor $ log2 $ pnorm Infinity m
-          log2 x = log x / log 2
+    where j = max 0 $ floor $ logBase 2 $ pnorm Infinity m
           a = m */ fromIntegral ((2::Int)^j)
           q = geps eps -- 7 steps
           eye = ident (rows m)
diff --git a/lib/Numeric/LinearAlgebra/Tests/Instances.hs b/lib/Numeric/LinearAlgebra/Tests/Instances.hs
--- a/lib/Numeric/LinearAlgebra/Tests/Instances.hs
+++ b/lib/Numeric/LinearAlgebra/Tests/Instances.hs
@@ -84,7 +84,7 @@
 
 #if MIN_VERSION_QuickCheck(2,0,0)
     -- shrink any one of the components
-    shrink a = map ((rows a) >< (cols a))
+    shrink a = map (rows a >< cols a)
                . shrinkListElementwise
                . concat . toLists 
                      $ a
diff --git a/lib/Numeric/LinearAlgebra/Tests/Properties.hs b/lib/Numeric/LinearAlgebra/Tests/Properties.hs
--- a/lib/Numeric/LinearAlgebra/Tests/Properties.hs
+++ b/lib/Numeric/LinearAlgebra/Tests/Properties.hs
@@ -159,7 +159,7 @@
           m = fromBlocks [[m'],[m']]
           r = rank m'
 
-svdProp5a m = and (map (s1|~|) [s2,s3,s4,s5,s6]) where
+svdProp5a m = all (s1|~|) [s2,s3,s4,s5,s6] where
     s1       = svR  m
     s2       = svRd m
     (_,s3,_) = svdR m
@@ -167,7 +167,7 @@
     (_,s5,_) = thinSVDR m
     (_,s6,_) = thinSVDRd m
 
-svdProp5b m = and (map (s1|~|) [s2,s3,s4,s5,s6]) where
+svdProp5b m = all (s1|~|) [s2,s3,s4,s5,s6] where
     s1       = svC  m
     s2       = svCd m
     (_,s3,_) = svdC m
diff --git a/lib/Numeric/Matrix.hs b/lib/Numeric/Matrix.hs
--- a/lib/Numeric/Matrix.hs
+++ b/lib/Numeric/Matrix.hs
@@ -3,7 +3,6 @@
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE UndecidableInstances #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE FunctionalDependencies #-}
 
 -----------------------------------------------------------------------------
 -- |
