diff --git a/layman/db.py b/layman/db.py
index 5019dfb..4603ef0 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -24,7 +24,7 @@ __version__ = "$Id: db.py 309 2007-04-09 16:23:38Z wrobel $"
 #
 #-------------------------------------------------------------------------------
 
-import os, codecs, os.path, urllib2, re, md5
+import os, codecs, os.path, urllib2, re, hashlib
 
 from   layman.utils             import path
 from   layman.overlay           import Overlays
@@ -318,7 +318,7 @@ class RemoteDB(Overlays):
 
         OUT.debug('Generating cache path.', 6)
 
-        return base + '_' + md5.md5(url).hexdigest() + '.xml'
+        return base + '_' + hashlib.md5(url).hexdigest() + '.xml'
 
 #===============================================================================
 #
@@ -332,7 +332,7 @@ class MakeConf:
 
     Check that an add/remove cycle does not modify the make.conf:
 
-    >>> import md5
+    >>> import hashlib
     >>> write = os.tmpnam()
     >>> here = os.path.dirname(os.path.realpath(__file__))
     >>> config = {'local_list' :
@@ -343,7 +343,7 @@ class MakeConf:
     ...           'quietness':3}
     >>> b = DB(config)
     >>> a = MakeConf(config, b.overlays)
-    >>> o_md5 = str(md5.md5(open(here + '/tests/testfiles/make.conf').read()).hexdigest())
+    >>> o_md5 = str(hashlib.md5(open(here + '/tests/testfiles/make.conf').read()).hexdigest())
     >>> a.path = write
     >>> a.add(b.overlays['wrobel-stable'])
     >>> [i.name for i in a.overlays]
@@ -358,7 +358,7 @@ class MakeConf:
     >>> [i.name for i in a.overlays]
     [u'wrobel', u'wrobel-stable']
     >>> a.delete(b.overlays['wrobel'])
-    >>> n_md5 = str(md5.md5(open(write).read()).hexdigest())
+    >>> n_md5 = str(hashlib.md5(open(write).read()).hexdigest())
     >>> o_md5 == n_md5
     True
     >>> os.unlink(write)
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 14aaa94..31d17c0 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -24,7 +24,7 @@ __version__ = "$Id: overlay.py 273 2006-12-30 15:54:50Z wrobel $"
 #
 #-------------------------------------------------------------------------------
 
-import sys, types, re, os, os.path, shutil, popen2
+import sys, types, re, os, os.path, shutil, subprocess
 
 from   layman.utils             import node_to_dict, dict_to_node, path
 
@@ -160,12 +160,8 @@ class Overlay:
         if not self.quiet:
             return os.system(command)
         else:
-            cmd = popen2.Popen4(command)
-            cmd.fromchild.readlines()
+            cmd = subprocess.Popen([command], stdout=PIPE, stderr=PIPE, close_fds=True)
             result = cmd.wait()
-            cmd.fromchild.readlines()
-            cmd.fromchild.close()
-            cmd.tochild.close()
             return result
 
     def __str__(self):