diff --git a/installsystems/repository.py b/installsystems/repository.py
index 6113d2b311370380f0a8206b39f37362dbf07369..95f1940f1342fcab7158523ece16d919663aa02c 100644
--- a/installsystems/repository.py
+++ b/installsystems/repository.py
@@ -148,7 +148,10 @@ class Repository(object):
     def get(self, name, version):
         '''return a package from a name and version of pakage'''
         desc = self.db.get(name, version)
-        return PackageImage(os.path.join(self.config.path, desc["md5"]), verbose=self.verbose)
+        p = PackageImage(os.path.join(self.config.path, desc["md5"]), verbose=self.verbose)
+        if p.md5 != desc["md5"]:
+            raise Exception("Invalid package MD5")
+        return p
 
 class RepositoryConfig(object):
     '''Repository configuration container'''
diff --git a/installsystems/tools.py b/installsystems/tools.py
index 504f048a02735bf2213a9c1bba3d079068fd103b..efe4b45743b8b1b022619d54c971058c95734e28 100644
--- a/installsystems/tools.py
+++ b/installsystems/tools.py
@@ -12,10 +12,18 @@ import shutil
 import urllib2
 from installsystems.tarball import Tarball
 
-def md5sum(path):
+def md5sum(path=None, fileobj=None):
     '''Compute md5 of a file'''
+    if path is None and fileobj is None:
+        raise ValueError("No path or fileobj specified")
+    if fileobj is None:
+        fileobj = uopen(path)
     m = hashlib.md5()
-    m.update(open(path, "r").read())
+    while True:
+        buf = fileobj.read(1024 * m.block_size)
+        if len(buf) == 0:
+            break
+        m.update(buf)
     return m.hexdigest()
 
 def copy(source, destination, uid=None, gid=None, mode=None, timeout=None):
@@ -92,22 +100,3 @@ def uopen(path):
         return urllib2.urlopen(path)
     else:
         raise NotImplementedError
-
-def extractdata(image, name, target, filelist=None):
-    '''Extract a databall name into target
-    This will be done accross a forking to allow higher performance and
-    on the fly checksumming
-    '''
-    filename = "%s-%s%s" % (image.id, name, image.extension_data)
-    if filename not in image.datas.keys():
-        raise Exception("No such data tarball in %s" % image.name)
-    datainfo = image.datas[filename]
-    fileobject = ropen(filename)
-    tarball = Tarball.open(fileobj=fileobject, mode="r|gz")
-    if filelist is None:
-        tarball.extractall(target)
-    else:
-        for f in filelist:
-            tarball.extract(f, target)
-    tarball.close()
-    fileobject.close()