diff --git a/Debian/Control/Text.hs b/Debian/Control/Text.hs
--- a/Debian/Control/Text.hs
+++ b/Debian/Control/Text.hs
@@ -29,7 +29,7 @@
 import qualified Data.ByteString.Char8 as B
 import Data.Char (toLower, chr)
 import Data.List (find)
-import qualified Data.Text as T (Text, pack, unpack, map, strip, reverse)
+import qualified Data.Text as T (Text, pack, unpack, map, dropAround, reverse)
 import Data.Text.Encoding (decodeUtf8With, encodeUtf8)
 --import Data.Text.IO as T (readFile)
 import qualified Debian.Control.ByteString as B
@@ -92,7 +92,8 @@
         where hasFieldName :: String -> Field' T.Text -> Bool
               hasFieldName name (Field (fieldName',_)) = T.pack name == T.map toLower fieldName'
               hasFieldName _ _ = False
-    stripWS = T.reverse . T.strip . T.reverse . T.strip
+    stripWS = T.dropAround (`elem` (" \t" :: String))
+      -- T.strip would also strip newlines
     protectFieldText = protectFieldText'
     asString = T.unpack
 
diff --git a/Debian/GenBuildDeps.hs b/Debian/GenBuildDeps.hs
--- a/Debian/GenBuildDeps.hs
+++ b/Debian/GenBuildDeps.hs
@@ -27,7 +27,8 @@
 import           Control.Applicative ((<$>))
 #endif
 import           Control.Exception (throw)
-import           Control.Monad (filterM)
+import           Control.Monad (filterM, foldM)
+import           Control.Monad.State (evalState, get, modify, State)
 import           Data.Graph (Graph, Edge, Vertex, buildG, topSort, reachable, transposeG, edges, scc)
 import           Data.List
 import qualified Data.Map as Map
@@ -39,6 +40,7 @@
 import           Debian.Loc (__LOC__)
 import           Debian.Relation
 import           Debian.Relation.Text ()
+-- import           Debug.Trace (trace)
 import           System.Directory (getDirectoryContents, doesFileExist)
 
 -- | This type describes the build dependencies of a source package.
@@ -46,6 +48,8 @@
       sourceName :: SrcPkgName          -- ^ source package name
     , relations :: Relations            -- ^ dependency relations
     , binaryNames :: [BinPkgName]       -- ^ binary dependency names (is this a function of relations?)
+    , depSet :: Set.Set BinPkgName          -- ^ Set containing all binary package names mentioned in relations
+    , binSet :: Set.Set BinPkgName          -- ^ Set containing binaryNames
     } deriving Show
 
 instance Eq DepInfo where
@@ -58,10 +62,14 @@
 -- <http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles>
 buildDependencies :: HasDebianControl control => control -> DepInfo
 buildDependencies control = do
+  let rels = concat [fromMaybe [] (debianBuildDeps control),
+                     fromMaybe [] (debianBuildDepsIndep control)]
+      bins = debianBinaryPackageNames control
   DepInfo { sourceName = debianSourcePackageName control
-          , relations = concat [fromMaybe [] (debianBuildDeps control),
-                                fromMaybe [] (debianBuildDepsIndep control)]
-          , binaryNames = debianBinaryPackageNames control }
+          , relations = rels
+          , binaryNames = bins
+          , depSet = Set.fromList (map (\(Rel x _ _) -> x) (concat rels))
+          , binSet = Set.fromList bins }
 
 -- | source package name
 sourceName' :: HasDebianControl control => control -> SrcPkgName
@@ -130,7 +138,8 @@
 buildable :: forall a. (a -> DepInfo) -> [a] -> BuildableInfo a
 buildable relax packages =
     -- Find all packages which can't reach any other packages in the
-    -- graph of the "has build dependency" relation.
+    -- graph of the "has build dependency" relation on the
+    -- yet-to-be-built packages
     case partition (\ x -> reachable hasDep x == [x]) verts of
       -- None of the packages are buildable, return information
       -- about how to break this build dependency cycle.
@@ -156,6 +165,7 @@
 
       hasDepEdges :: [(Int, Int)]
       hasDepEdges =
+#if 0
           nub (foldr f [] (tails vertPairs))
           where f :: [(Int, DepInfo)] -> [(Int, Int)] -> [(Int, Int)]
                 f [] es = es
@@ -166,6 +176,26 @@
                       EQ -> Nothing
                       LT -> Just (yv, xv)
                       GT -> Just (xv, yv)
+#else
+          nub (evalState (foldM f [] (tails vertPairs)) Map.empty)
+          where f :: [(Int, Int)] -> [(Int, DepInfo)] -> State (Map.Map (Int, Int) Ordering) [(Int, Int)]
+                f es [] = return es
+                f es (x : xs) = mapM (toEdge x) xs >>= \es' -> return (catMaybes es' ++ es)
+                toEdge :: (Int, DepInfo) -> (Int, DepInfo) -> State (Map.Map (Int, Int) Ordering) (Maybe Edge)
+                toEdge (xv, xa) (yv, ya) = do
+                  mp <- get
+                  r <- case Map.lookup (xv, yv) mp of
+                         Just r' -> return r'
+                         Nothing -> do
+                           let r' = compareSource xa ya
+                           -- trace ("compareSource " ++ show (unSrcPkgName $ sourceName xa) ++ " " ++ show (unSrcPkgName $ sourceName ya) ++ " -> " ++ show r') (return ())
+                           modify (Map.insert (xv, yv) r')
+                           return r'
+                  case r of
+                    EQ -> return Nothing
+                    LT -> return $ Just (yv, xv)
+                    GT -> return $ Just (xv, yv)
+#endif
       ofEdge :: Edge -> (a, a)
       ofEdge (a, b) = (ofVertex a, ofVertex b)
       ofVertex :: Int -> a
@@ -242,9 +272,14 @@
 -- a pretty simplistic approach to 'or' build depends. However, I
 -- think this should work pretty nicely in practice.
 compareSource :: DepInfo -> DepInfo -> Ordering
-compareSource (DepInfo {relations = depends1, binaryNames = bins1}) (DepInfo {relations = depends2, binaryNames = bins2})
-    | any (\rel -> isJust (find (checkPackageNameReq rel) bins2)) (concat depends1) = GT
-    | any (\rel -> isJust (find (checkPackageNameReq rel) bins1)) (concat depends2) = LT
+compareSource p1 p2
+#if 0
+    | any (\rel -> isJust (find (checkPackageNameReq rel) (binaryNames p2))) (concat (relations p1)) = GT
+    | any (\rel -> isJust (find (checkPackageNameReq rel) (binaryNames p1))) (concat (relations p2)) = LT
+#else
+    | not (null (Set.intersection (depSet p1) (binSet p2))) = GT
+    | not (null (Set.intersection (depSet p2) (binSet p1))) = LT
+#endif
     | otherwise = EQ
     where
       checkPackageNameReq :: Relation -> BinPkgName -> Bool
diff --git a/changelog b/changelog
--- a/changelog
+++ b/changelog
@@ -2,6 +2,7 @@
 
   * Functor, Applicative, and Alternative instances for ghc-7.10
   * Fiddle with imports and ifdefs to fix build
+  * Switch from ansi-wl-pprint package to pretty
 
  -- David Fox <dsf@seereason.com>  Sun, 22 Mar 2015 12:55:39 -0700
 
diff --git a/debian.cabal b/debian.cabal
--- a/debian.cabal
+++ b/debian.cabal
@@ -1,5 +1,5 @@
 Name:           debian
-Version:        3.87.2
+Version:        3.88
 License:        BSD3
 License-File:   debian/copyright
 Author:         David Fox <dsf@seereason.com>, Jeremy Shaw <jeremy@seereason.com>, Clifford Beshers <beshers@seereason.com>
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+haskell-debian (3.88) unstable; urgency=low
+
+  * Improved handling of white space
+  * Speed up Debian.GenBuildDeps.buildable
+
+ -- David Fox <dsf@seereason.com>  Mon, 24 Aug 2015 06:29:29 -0700
+
 haskell-debian (3.87.2) unstable; urgency=low
 
   * Functor, Applicative, and Alternative instances for ghc-7.10
