diff --git a/.gitignore b/.gitignore
deleted file mode 100644
--- a/.gitignore
+++ /dev/null
@@ -1,1 +0,0 @@
-dist/
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "cabal"]
-	path = cabal
-	url = git://github.com/gentoo-haskell/cabal.git
diff --git a/Merge.hs b/Merge.hs
--- a/Merge.hs
+++ b/Merge.hs
@@ -6,17 +6,31 @@
 
 import Control.Monad.Error
 import Control.Exception
+import qualified Data.ByteString.Lazy.Char8 as BL
 import Data.Maybe
 import Data.List as L
-import Distribution.Package
-import Distribution.PackageDescription ( PackageDescription(..)
+import Data.Version
+
+-- cabal
+import qualified Distribution.Package as Cabal
+import qualified Distribution.Version as Cabal
+import qualified Distribution.PackageDescription as Cabal ( PackageDescription(..)
                                        , FlagName(..)
-                                       , GenericPackageDescription
+                                       , GenericPackageDescription(..)
                                        )
-import Distribution.PackageDescription.Configuration
-         ( finalizePackageDescription )
+import qualified Distribution.PackageDescription.Configuration as Cabal ( finalizePackageDescription )
+
+import Distribution.System (buildPlatform)
 import Distribution.Text (display)
+import Distribution.Verbosity
+import Distribution.Simple.Utils
 
+-- cabal-install
+import Distribution.Client.IndexUtils ( getSourcePackages )
+import qualified Distribution.Client.PackageIndex as Index
+import Distribution.Client.Types
+
+-- others
 import System.Directory ( getCurrentDirectory
                         , setCurrentDirectory
                         , createDirectoryIfMissing
@@ -30,18 +44,8 @@
 import qualified Portage.EBuild as E
 import Error as E
 
-import qualified Distribution.Package as Cabal
-import qualified Distribution.Version as Cabal
-
-import Distribution.System (buildPlatform)
-import Distribution.Verbosity
-import Distribution.Simple.Utils
-
 import Network.URI
 
-import Distribution.Client.IndexUtils ( getSourcePackages )
-import qualified Distribution.Client.PackageIndex as Index
-import Distribution.Client.Types
 
 import qualified Portage.PackageId as Portage
 import qualified Portage.Version as Portage
@@ -53,8 +57,6 @@
 
 import qualified Merge.Dependencies as Merge
 
-import Debug.Trace ( trace )
-
 (<.>) :: String -> String -> String
 a <.> b = a ++ '.':b
 
@@ -93,7 +95,7 @@
 resolveVersion avails Nothing = Just $ maximumBy (comparing packageInfoId) avails
 resolveVersion avails (Just ver) = listToMaybe (filter match avails)
   where
-    match avail = ver == pkgVersion (packageInfoId avail)
+    match avail = ver == Cabal.pkgVersion (packageInfoId avail)
 
 merge :: Verbosity -> Repo -> URI -> [String] -> FilePath -> IO ()
 merge verbosity repo _serverURI args overlayPath = do
@@ -123,9 +125,15 @@
     case map snd (Index.searchByName index user_pname_str) of
       [] -> throwEx (PackageNotFound user_pname_str)
       [pkg] -> return pkg
-      pkgs  -> let names      = map (pkgName . packageInfoId . L.head) pkgs
-                   whole_list = map (L.intercalate "\n" . map (show . packageInfoId)) pkgs
-               in throwEx $ ArgumentError $ L.intercalate "\n---\n" $ ["Ambiguous names: " ++ show names] ++ whole_list
+      pkgs  -> do let cabal_pkg_to_pn pkg =
+                          case Cabal.pkgName (packageInfoId pkg) of
+                              Cabal.PackageName pn -> pn
+                      names      = map (cabal_pkg_to_pn . L.head) pkgs
+                  notice verbosity $ "Ambiguous names: " ++ L.intercalate ", " names
+                  forM_ pkgs $ \ps ->
+                      do let p_name = (cabal_pkg_to_pn . L.head) ps
+                         notice verbosity $ p_name ++ ": " ++ (L.intercalate ", " $ map (showVersion . Cabal.pkgVersion . packageInfoId) ps)
+                  return $ concat pkgs
 
   -- select a single package taking into account the user specified version
   selectedPkg <-
@@ -145,20 +153,22 @@
     info verbosity $ match_text ++ (display . packageInfoId $ avail)
 
   let cabal_pkgId = packageInfoId selectedPkg
-      norm_pkgName = packageName (Portage.normalizeCabalPackageId cabal_pkgId)
+      norm_pkgName = Cabal.packageName (Portage.normalizeCabalPackageId cabal_pkgId)
   cat <- maybe (Portage.resolveCategory verbosity overlay norm_pkgName) return m_category
   mergeGenericPackageDescription verbosity overlayPath cat (packageDescription selectedPkg) True
 
-mergeGenericPackageDescription :: Verbosity -> FilePath -> Portage.Category -> GenericPackageDescription -> Bool -> IO ()
+mergeGenericPackageDescription :: Verbosity -> FilePath -> Portage.Category -> Cabal.GenericPackageDescription -> Bool -> IO ()
 mergeGenericPackageDescription verbosity overlayPath cat pkgGenericDesc fetch = do
   overlay <- Overlay.loadLazy overlayPath
+  let merged_cabal_pkg_name = Cabal.pkgName (Cabal.package (Cabal.packageDescription pkgGenericDesc))
+
   let Right (pkgDesc0, flags) =
-        finalizePackageDescription
+        Cabal.finalizePackageDescription
           [ -- XXX: common things we should enable/disable?
             -- (FlagName "small_base", True) -- try to use small base
-            (FlagName "cocoa", False)
+            (Cabal.FlagName "cocoa", False)
           ]
-          (\dep -> trace ("accepting dep(?): " ++ display dep) True)
+          (\_dep -> True)
           -- (Nothing :: Maybe (Index.PackageIndex PackageIdentifier))
           buildPlatform
           (fst GHCCore.defaultGHC)
@@ -167,17 +177,27 @@
       mminimumGHC = GHCCore.minimumGHCVersionToBuildPackage pkgGenericDesc
       (compilerId, excludePkgs) = maybe GHCCore.defaultGHC id mminimumGHC
 
-      pkgDesc = let deps = [ Dependency pn (Cabal.simplifyVersionRange vr)
-                           | Dependency pn vr <- buildDepends pkgDesc0
-                           , pn `notElem` excludePkgs
-                           ]
-                in pkgDesc0 { buildDepends = deps }
+      (accepted_deps, skipped_deps, dropped_deps) =
+          foldl (\(ad, sd, rd) (Cabal.Dependency pn vr) ->
+                  let dep = (Cabal.Dependency pn (Cabal.simplifyVersionRange vr))
+                  in case () of
+                        _ | pn `elem` excludePkgs       -> (    ad, dep:sd,     rd)
+                        _ | pn == merged_cabal_pkg_name -> (    ad,     sd, dep:rd)
+                        _                               -> (dep:ad,     sd,     rd)
+                )
+                ([],[],[])
+                (Cabal.buildDepends pkgDesc0)
+      pkgDesc = pkgDesc0 { Cabal.buildDepends = accepted_deps }
+
       edeps = Merge.resolveDependencies overlay pkgDesc (Just compilerId)
 
-  debug verbosity ("Selected flags: " ++ show flags)
+  notice verbosity $ "Accepted depends: " ++ show (map display accepted_deps)
+  notice verbosity $ "Skipped  depends: " ++ show (map display skipped_deps)
+  notice verbosity $ "Dropped  depends: " ++ show (map display dropped_deps)
+  notice verbosity $ "Selected flags: " ++ show flags
   info verbosity ("Guessing GHC version: " ++ maybe "could not guess" (display.fst) mminimumGHC)
   forM_ excludePkgs $
-      \(PackageName name) -> info verbosity $ "Excluded packages (come with ghc): " ++ name
+      \(Cabal.PackageName name) -> info verbosity $ "Excluded packages (comes with ghc): " ++ name
 
   let ebuild =   (\e -> e { E.depend        = Merge.dep edeps } )
                . (\e -> e { E.depend_extra  = Merge.dep_e edeps } )
@@ -187,8 +207,8 @@
 
   mergeEbuild verbosity overlayPath (Portage.unCategory cat) ebuild
   when fetch $ do
-    let cabal_pkgId = packageId pkgDesc
-        norm_pkgName = packageName (Portage.normalizeCabalPackageId cabal_pkgId)
+    let cabal_pkgId = Cabal.packageId pkgDesc
+        norm_pkgName = Cabal.packageName (Portage.normalizeCabalPackageId cabal_pkgId)
     fetchAndDigest
       verbosity
       (overlayPath </> display cat </> display norm_pkgName)
@@ -219,15 +239,15 @@
       epath = edir </> elocal
       emeta = "metadata.xml"
       mpath = edir </> emeta
-      default_meta = Portage.makeDefaultMetadata (E.long_desc ebuild)
+      default_meta = BL.pack $ Portage.makeDefaultMetadata (E.long_desc ebuild)
   createDirectoryIfMissing True edir
   notice verbosity $ "Writing " ++ elocal
-  writeFile epath (display ebuild)
+  BL.writeFile epath (BL.pack $ display ebuild)
 
   yet_meta <- doesFileExist mpath
   if (not yet_meta) -- TODO: add --force-meta-rewrite to opts
       then do notice verbosity $ "Writing " ++ emeta
-              writeFile mpath default_meta
-      else do current_meta <- readFile mpath
+              BL.writeFile mpath default_meta
+      else do current_meta <- BL.readFile mpath
               when (current_meta /= default_meta) $
                   notice verbosity $ "Default and current " ++ emeta ++ " differ."
diff --git a/Merge/Dependencies.hs b/Merge/Dependencies.hs
--- a/Merge/Dependencies.hs
+++ b/Merge/Dependencies.hs
@@ -58,11 +58,13 @@
                                        , TestSuite(..)
                                        , targetBuildDepends
                                        )
-import Data.Maybe ( isNothing )
+import Data.Maybe ( isJust, isNothing )
 import Data.List ( nub )
 
 import qualified Distribution.Package as Cabal
+import qualified Distribution.PackageDescription as Cabal
 import qualified Distribution.Version as Cabal
+
 import Distribution.Compiler
 
 import qualified Portage.Dependency as Portage
@@ -111,7 +113,7 @@
     compiler = maybe (fst GHCCore.defaultGHC) id mcompiler
 
     hasBuildableExes p = any (buildable . buildInfo) . executables $ p
-    treatAsLibrary = (not . hasBuildableExes) pkg || hasLibs pkg
+    treatAsLibrary = isJust (Cabal.library pkg)
     haskell_deps
         | treatAsLibrary = map set_build_slot $ map add_profile $ haskellDependencies overlay pkg
         | otherwise      = haskellDependencies overlay pkg
@@ -224,7 +226,7 @@
 staticTranslateExtraLib lib = lookup lib m
   where
   m = [ ("z", Portage.AnyVersionOf (Portage.mkPackageName "sys-libs" "zlib") Portage.AnySlot [])
-      , ("bz2", Portage.AnyVersionOf (Portage.mkPackageName "sys-libs" "bzlib") Portage.AnySlot [])
+      , ("bz2", Portage.AnyVersionOf (Portage.mkPackageName "app-arch" "bzip2") Portage.AnySlot [])
       , ("mysqlclient", Portage.LaterVersionOf (Portage.Version [4,0] Nothing [] 0) (Portage.mkPackageName "virtual" "mysql") Portage.AnySlot [])
       , ("pq", Portage.LaterVersionOf (Portage.Version [7] Nothing [] 0) (Portage.mkPackageName "dev-db" "postgresql-base") Portage.AnySlot [])
       , ("ev", Portage.AnyVersionOf (Portage.mkPackageName "dev-libs" "libev") Portage.AnySlot [])
@@ -234,6 +236,15 @@
       , ("mecab", Portage.AnyVersionOf (Portage.mkPackageName "app-text" "mecab") Portage.AnySlot [])
       , ("zmq", Portage.AnyVersionOf (Portage.mkPackageName "net-libs" "zeromq") Portage.AnySlot [])
       , ("SDL", Portage.AnyVersionOf (Portage.mkPackageName "media-libs" "libsdl") Portage.AnySlot [])
+      , ("adns", Portage.AnyVersionOf (Portage.mkPackageName "net-libs" "adns") Portage.AnySlot [])
+      , ("pcre", Portage.AnyVersionOf (Portage.mkPackageName "dev-libs" "libpcre") Portage.AnySlot [])
+      , ("GL", Portage.AnyVersionOf (Portage.mkPackageName "virtual" "opengl") Portage.AnySlot [])
+      , ("GLU", Portage.AnyVersionOf (Portage.mkPackageName "virtual" "glu") Portage.AnySlot [])
+      , ("glut", Portage.AnyVersionOf (Portage.mkPackageName "media-libs" "freeglut") Portage.AnySlot [])
+      , ("X11", Portage.AnyVersionOf (Portage.mkPackageName "x11-libs" "libX11") Portage.AnySlot [])
+      , ("libzip", Portage.AnyVersionOf (Portage.mkPackageName "dev-libs" "libzip") Portage.AnySlot [])
+      , ("ssl", Portage.AnyVersionOf (Portage.mkPackageName "dev-libs" "openssl") Portage.AnySlot [])
+      , ("Judy", Portage.AnyVersionOf (Portage.mkPackageName "dev-libs" "judy") Portage.AnySlot [])
       ]
 
 ---------------------------------------------------------------
@@ -359,5 +370,6 @@
   ,("curl",                        ("net-misc", "curl", Portage.AnySlot))
   ,("libxml2",                     ("dev-libs", "libxml2", Portage.AnySlot))
   ,("libgsasl",                    ("virtual", "gsasl", Portage.AnySlot))
+  ,("libzip",                      ("dev-libs", "libzip", Portage.AnySlot))
 
   ]
diff --git a/Portage/GHCCore.hs b/Portage/GHCCore.hs
--- a/Portage/GHCCore.hs
+++ b/Portage/GHCCore.hs
@@ -20,12 +20,15 @@
 
 import Data.Maybe
 import Data.List ( nub )
+import Data.Version
 
+import Debug.Trace
+
 defaultGHC :: (CompilerId, [PackageName])
 defaultGHC = let (g,pix) = ghc6123 in (g, packageNamesFromPackageIndex pix)
 
 ghcs :: [(CompilerId, PackageIndex)]
-ghcs = [ghc6104, ghc6121, ghc6122, ghc6123, ghc701, ghc742, ghc761]
+ghcs = [ghc6104, ghc6121, ghc6122, ghc6123, ghc704, ghc741, ghc742, ghc761]
 
 cabalFromGHC :: [Int] -> Maybe Version
 cabalFromGHC ver = lookup ver table
@@ -71,8 +74,20 @@
   :: GenericPackageDescription
   -> (CompilerId, PackageIndex)
   -> Either [Dependency] (PackageDescription, FlagAssignment)
-packageBuildableWithGHCVersion pkg (compiler, pkgIndex) =
+packageBuildableWithGHCVersion pkg (compiler, pkgIndex) = trace_failure $
   finalizePackageDescription [] (dependencySatisfiable pkgIndex) platform compiler [] pkg
+    where trace_failure v = case v of
+              (Left deps) -> trace (unwords ["rejecting dep:" , show_compiler compiler
+                                            , "as", show_deps deps
+                                            , "were not found."
+                                            ]
+                                   ) v
+              _           -> trace (unwords ["accepting dep:" , show_compiler compiler
+                                            ]
+                                   ) v
+          show_deps = show . map display
+          show_compiler (CompilerId GHC v) = "ghc-" ++ showVersion v
+          show_compiler c = show c
 
 -- | Given a 'GenericPackageDescription' it returns the miminum GHC version
 -- to build a package, and a list of core packages to that GHC version.
@@ -100,11 +115,14 @@
 ghc761 :: (CompilerId, PackageIndex)
 ghc761 = (ghc [7,6,1], mkIndex ghc761_pkgs)
 
+ghc741 :: (CompilerId, PackageIndex)
+ghc741 = (ghc [7,4,1], mkIndex ghc741_pkgs)
+
 ghc742 :: (CompilerId, PackageIndex)
 ghc742 = (ghc [7,4,2], mkIndex ghc742_pkgs)
 
-ghc701 :: (CompilerId, PackageIndex)
-ghc701 = (ghc [7,0,1], mkIndex ghc701_pkgs)
+ghc704 :: (CompilerId, PackageIndex)
+ghc704 = (ghc [7,0,1], mkIndex ghc704_pkgs)
 
 ghc6123 :: (CompilerId, PackageIndex)
 ghc6123 = (ghc [6,12,3], mkIndex ghc6123_pkgs)
@@ -129,7 +147,7 @@
   , p "bytestring" [0,10,0,8]
 --  , p "Cabal" [1,16,0]  package is upgradeable
   , p "containers" [0,5,0,0]
-  , p "deepseq" [1,3,0,1]
+--  , p "deepseq" [1,3,0,1] -- package is upgradeable
   , p "directory" [1,2,0,0]
   , p "filepath" [1,3,0,1]
   , p "ghc-prim" [0,3,0,0]
@@ -143,18 +161,19 @@
   , p "pretty" [1,1,1,0]
   , p "process" [1,1,0,2]
   , p "template-haskell" [2,8,0,0] -- used by libghc
-  , p "time" [1,4,0,1] -- used by haskell98
+-- , p "time" [1,4,0,1] -- upgradeable, but used by haskell98
   , p "unix" [2,6,0,0]
   ]
 
 ghc742_pkgs :: [PackageIdentifier]
-ghc742_pkgs = 
+ghc742_pkgs =
   [ p "array" [0,4,0,0]
   , p "base" [4,5,1,0]
 --  , p "binary" [0,5,1,0]  package is upgradeable
-  , p "bytestring" [0,9,1,8]
+  , p "bytestring" [0,9,2,1]
 --  , p "Cabal" [1,14,0]  package is upgradeable
   , p "containers" [0,4,2,1]
+--  , p "deepseq" [1,3,0,0]  package is upgradeable
   , p "directory" [1,1,0,2]
 -- , p "extensible-exceptions" [0,1,1,4] -- package is upgradeable, stopped shipping in 7.6
   , p "filepath" [1,3,0,0]
@@ -169,34 +188,61 @@
   , p "pretty" [1,1,1,0]
   , p "process" [1,1,0,1]
   , p "template-haskell" [2,7,0,0] -- used by libghc
-  , p "time" [1,4] -- used by haskell98
+-- , p "time" [1,4] -- upgradeable, but used by haskell98
   , p "unix" [2,5,1,1]
   ]
 
-ghc701_pkgs :: [PackageIdentifier]
-ghc701_pkgs =
+ghc741_pkgs :: [PackageIdentifier]
+ghc741_pkgs =
+  [ p "array" [0,4,0,0]
+  , p "base" [4,5,0,0]
+--  , p "binary" [0,5,1,0]  package is upgradeable
+  , p "bytestring" [0,9,2,1]
+--  , p "Cabal" [1,14,0]  package is upgradeable
+  , p "containers" [0,4,2,1]
+--  , p "deepseq" [1,3,0,0]  package is upgradeable
+  , p "directory" [1,1,0,2]
+-- , p "extensible-exceptions" [0,1,1,4] -- package is upgradeable, stopped shipping in 7.6
+  , p "filepath" [1,3,0,0]
+  , p "ghc-prim" [0,2,0,0]
+  , p "haskell2010" [1,1,0,1]
+  , p "haskell98" [2,0,0,1]
+  , p "hoopl" [3,8,7,3] -- used by libghc
+  , p "hpc" [0,5,1,1] -- used by libghc
+  , p "integer-gmp" [0,4,0,0]
+  , p "old-locale" [1,0,0,4]
+  , p "old-time" [1,1,0,0]
+  , p "pretty" [1,1,1,0]
+  , p "process" [1,1,0,1]
+  , p "template-haskell" [2,7,0,0] -- used by libghc
+-- , p "time" [1,4] -- upgradeable, but used by haskell98
+  , p "unix" [2,5,1,0]
+  ]
+
+ghc704_pkgs :: [PackageIdentifier]
+ghc704_pkgs =
   [ p "array" [0,3,0,2]
-  , p "base" [4,3,0,0]
-  , p "bytestring" [0,9,1,8]
---  , p "Cabal" [1,10,0,0]  package is upgradeable
+  , p "base" [4,3,1,0]
+  , p "bytestring" [0,9,1,10]
+--  , p "Cabal" [1,10,2,0]  package is upgradeable
   , p "containers" [0,4,0,0]
   , p "directory" [1,1,0,0]
 -- , p "extensible-exceptions" [0,1,1,2] -- package is upgradeable, stopped shipping in 7.6
   , p "filepath" [1,2,0,0]
+  , p "ghc-binary" [0,5,0,2]
+  , p "ghc-prim" [0,2,0,0]
   , p "haskell2010" [1,0,0,0]
-  , p "haskell98" [1,1,0,0]
+  , p "haskell98" [1,1,0,1]
   , p "hpc" [0,5,0,6]
   , p "integer-gmp" [0,2,0,2]
-  , p "integer-simple" [0,1,0,0]
   , p "old-locale" [1,0,0,2]
   , p "old-time" [1,0,0,6]
   , p "pretty" [1,0,1,2]
-  , p "process" [1,0,1,4]
+  , p "process" [1,0,1,5]
 --   , p "random" [1,0,0,3] -- will not be shipped starting from ghc-7.2
   , p "template-haskell" [2,5,0,0]
 --  , p "time" [1,2,0,3] package is upgradeable
-  , p "unix" [2,4,1,0]
---  , p "utf8-string" [0,3,4] package is upgradeable
+  , p "unix" [2,4,2,0]
   ]
 
 ghc6123_pkgs :: [PackageIdentifier]
@@ -210,6 +256,8 @@
   , p "directory" [1,0,1,1]
 -- , p "extensible-exceptions" [0,1,1,1] -- package is upgradeable, stopped shipping in 7.6
   , p "filepath" [1,1,0,4]
+  , p "ghc-binary" [0,5,0,2]
+  , p "ghc-prim" [0,2,0,0]
   , p "haskell98" [1,0,1,1]
   , p "hpc" [0,5,0,5]
   , p "integer-gmp" [0,2,0,1]
@@ -237,10 +285,11 @@
   , p "directory" [1,0,1,1]
 --  , p "extensible-exceptions" [0,1,1,1] -- package is upgradeable, stopped shipping in 7.6
   , p "filepath" [1,1,0,4]
+  , p "ghc-binary" [0,5,0,2]
+  , p "ghc-prim" [0,2,0,0]
   , p "haskell98" [1,0,1,1]
   , p "hpc" [0,5,0,5]
   , p "integer-gmp" [0,2,0,1]
-  , p "integer-simple" [0,1,0,0]
   , p "old-locale" [1,0,0,2]
   , p "old-time" [1,0,0,4]
   , p "pretty" [1,0,1,1]
@@ -264,10 +313,11 @@
   , p "directory" [1,0,1,0]
 --  , p "extensible-exceptions" [0,1,1,1] -- package is upgradeable, stopped shipping in 7.6
   , p "filepath" [1,1,0,3]
+  , p "ghc-binary" [0,5,0,2]
+  , p "ghc-prim" [0,2,0,0]
   , p "haskell98" [1,0,1,1]
   , p "hpc" [0,5,0,4]
   , p "integer-gmp" [0,2,0,0]
-  , p "integer-simple" [0,1,0,0]
   , p "old-locale" [1,0,0,2]
   , p "old-time" [1,0,0,3]
   , p "pretty" [1,0,1,1]
@@ -287,12 +337,14 @@
   , p "base" [4,1,0,0]
   , p "bytestring" [0,9,1,4]
 --  , p "Cabal" [1,6,0,3] package is upgradeable
-  , p "containers" [0,2,0,1 ]
+  , p "containers" [0,2,0,1]
   , p "directory" [1,0,0,3]
 --  , p "extensible-exceptions" [0,1,1,0] -- package is upgradeable, stopped shipping in 7.6
   , p "filepath" [1,1,0,2]
+  , p "ghc-prim" [0,1,0,0]
   , p "haskell98" [1,0,1,0]
   , p "hpc" [0,5,0,3]
+  , p "integer" [0,1,0,1]
   , p "old-locale" [1,0,0,1]
   , p "old-time" [1,0,0,2]
   , p "packedstring" [0,1,0,1]
diff --git a/Portage/Resolve.hs b/Portage/Resolve.hs
--- a/Portage/Resolve.hs
+++ b/Portage/Resolve.hs
@@ -48,7 +48,7 @@
 resolveCategories overlay pn =
   [ cat 
   | (Portage.PackageName cat pn') <- Map.keys om
-  , pn == Portage.normalizeCabalPackageName pn'
+  , Portage.normalizeCabalPackageName pn == pn'
   ]
   where
     om = Overlay.overlayMap overlay
@@ -61,7 +61,7 @@
     cats | (cat:_) <- (filter (`elem` cats) priority) -> ret cat
          | otherwise -> trace ("Ambiguous package name: " ++ show pn ++ ", hits: " ++ show cats) Nothing
   where
-  ret c = return (Portage.PackageName c pn)
+  ret c = return (Portage.PackageName c (Portage.normalizeCabalPackageName pn))
   mkC = Portage.Category
   -- if any of these categories show up in the result list, the match isn't
   -- ambiguous, pick the first match in the list
diff --git a/Status.hs b/Status.hs
--- a/Status.hs
+++ b/Status.hs
@@ -81,6 +81,7 @@
 loadHackage verbosity repo overlay = do
     SourcePackageDb { packageIndex = pindex } <- CabalInstall.getSourcePackages verbosity [repo]
     let get_cat cabal_pkg = case resolveCategories overlay (pkgName cabal_pkg) of
+                                []    -> Category "dev-haskell"
                                 [cat] -> cat
                                 _     -> {- ambig -} Category "dev-haskell"
         pkg_infos = map ( reverse . take 3 . reverse -- hackage usually has a ton of older versions
diff --git a/cabal/.git b/cabal/.git
deleted file mode 100644
--- a/cabal/.git
+++ /dev/null
@@ -1,1 +0,0 @@
-gitdir: /home/slyfox/portage/hackport/.git/modules/cabal
diff --git a/cabal/.gitignore b/cabal/.gitignore
deleted file mode 100644
--- a/cabal/.gitignore
+++ /dev/null
@@ -1,25 +0,0 @@
-# trivial gitignore file
-
-cabal-dev/
-Cabal/dist/
-cabal-install/dist/
-.hpc/
-*.hi
-*.o
-*.p_hi
-*.prof
-*.tix
-
-# editor temp files
-
-*#
-.#*
-*~
-.*.swp
-
-# GHC build
-
-Cabal/GNUmakefile
-Cabal/dist-boot/
-Cabal/dist-install/
-Cabal/ghc.mk
diff --git a/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive1/GlobalBuildDepsN b/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive1/GlobalBuildDepsN
new file mode 100644
--- /dev/null
+++ b/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive1/GlobalBuildDepsN
@@ -0,0 +1,20 @@
+name: GlobalBuildDepsNotAdditive1
+version: 0.1
+license: BSD3
+cabal-version: >= 1.6
+author: Stephen Blackheath
+stability: stable
+category: PackageTests
+build-type: Simple
+
+description:
+    If you specify 'base' in the global build dependencies, then define
+    a library without base, it fails to find 'base' for the library.
+
+---------------------------------------
+
+build-depends: base
+
+Library
+    exposed-modules: MyLibrary
+    build-depends: bytestring, old-time
diff --git a/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive1/GlobalBuildDepsNot b/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive1/GlobalBuildDepsNot
deleted file mode 100644
--- a/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive1/GlobalBuildDepsNot
+++ /dev/null
@@ -1,20 +0,0 @@
-name: GlobalBuildDepsNotAdditive1
-version: 0.1
-license: BSD3
-cabal-version: >= 1.6
-author: Stephen Blackheath
-stability: stable
-category: PackageTests
-build-type: Simple
-
-description:
-    If you specify 'base' in the global build dependencies, then define
-    a library without base, it fails to find 'base' for the library.
-
----------------------------------------
-
-build-depends: base
-
-Library
-    exposed-modules: MyLibrary
-    build-depends: bytestring, old-time
diff --git a/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive2/GlobalBuildDepsN b/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive2/GlobalBuildDepsN
new file mode 100644
--- /dev/null
+++ b/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive2/GlobalBuildDepsN
@@ -0,0 +1,20 @@
+name: GlobalBuildDepsNotAdditive1
+version: 0.1
+license: BSD3
+cabal-version: >= 1.6
+author: Stephen Blackheath
+stability: stable
+category: PackageTests
+build-type: Simple
+
+description:
+    If you specify 'base' in the global build dependencies, then define
+    an executable without base, it fails to find 'base' for the executable
+
+---------------------------------------
+
+build-depends: base
+
+Executable lemon
+    main-is: lemon.hs
+    build-depends: bytestring, old-time
diff --git a/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive2/GlobalBuildDepsNot b/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive2/GlobalBuildDepsNot
deleted file mode 100644
--- a/cabal/Cabal/tests/PackageTests/BuildDeps/GlobalBuildDepsNotAdditive2/GlobalBuildDepsNot
+++ /dev/null
@@ -1,20 +0,0 @@
-name: GlobalBuildDepsNotAdditive1
-version: 0.1
-license: BSD3
-cabal-version: >= 1.6
-author: Stephen Blackheath
-stability: stable
-category: PackageTests
-build-type: Simple
-
-description:
-    If you specify 'base' in the global build dependencies, then define
-    an executable without base, it fails to find 'base' for the executable
-
----------------------------------------
-
-build-depends: base
-
-Executable lemon
-    main-is: lemon.hs
-    build-depends: bytestring, old-time
diff --git a/hackport.cabal b/hackport.cabal
--- a/hackport.cabal
+++ b/hackport.cabal
@@ -1,5 +1,5 @@
 Name:           hackport
-Version:	0.3
+Version:	0.3.1
 License:	GPL
 License-file:   LICENSE
 Author:		Henning Günther, Duncan Coutts, Lennart Kolmodin
diff --git a/tests/resolveCat.hs b/tests/resolveCat.hs
--- a/tests/resolveCat.hs
+++ b/tests/resolveCat.hs
@@ -12,6 +12,8 @@
 
 tests = TestList [ TestLabel "resolve cabal" (test_resolveCategory "dev-haskell" "cabal")
                  , TestLabel "resolve ghc" (test_resolveCategory "dev-lang" "ghc")
+                 , TestLabel "resolve Cabal" (test_resolveCategory "dev-haskell" "Cabal")
+                 , TestLabel "resolve DaRsC" (test_resolveCategory "dev-vcs" "darcs")
                  ]
 
 test_resolveCategory :: String -> String -> Test
@@ -20,8 +22,8 @@
   portage <- Portage.loadLazy portage_dir
   let cabal = Cabal.PackageName pkg
       hits = Portage.resolveFullPortageName portage cabal
-      expected = Just (Portage.PackageName (Portage.Category cat) cabal)
-  assertEqual ("expecting to find package " ++ pkg) hits expected 
+      expected = Just (Portage.PackageName (Portage.Category cat) (Portage.normalizeCabalPackageName cabal))
+  assertEqual ("expecting to find package " ++ pkg) expected hits
 
 something_broke :: Counts -> Bool
 something_broke stats = errors stats + failures stats > 0
