diff --git a/src/chat_control.py b/src/chat_control.py
index 5c6989462155f6e4a0ea66fd50f2fc8c559f95c3..6c0976ea5e0ec77f4509f868869d3cab12a6b45c 100644
--- a/src/chat_control.py
+++ b/src/chat_control.py
@@ -46,8 +46,7 @@ from message_control import MessageControl
 from conversation_textview import ConversationTextview
 from message_textview import MessageTextView
 from common.contacts import GC_Contact
-from common.logger import Constants
-constants = Constants()
+from common.logger import constants
 from common.pep import MOODS, ACTIVITIES
 from common.xmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC
 from common.xmpp.protocol import NS_RECEIPTS, NS_ESESSION
@@ -2451,7 +2450,7 @@ class ChatControl(ChatControlBase):
 				pending_how_many, timeout, self.account)
 		except exceptions.DatabaseMalformed:
 			dialogs.ErrorDialog(_('Database Error'),
-				_('The database file (%s) cannot be read. Try to repair it or remove it (all history will be lost).') % common.logger.LOG_DB_PATH)
+				_('The database file (%s) cannot be read. Try to repair it or remove it (all history will be lost).') % constants.LOG_DB_PATH)
 			rows = []
 		local_old_kind = None
 		for row in rows: # row[0] time, row[1] has kind, row[2] the message
diff --git a/src/common/caps.py b/src/common/caps.py
index 358645e764161a36eebf1e9aeacbebbc6e5d321c..d4ef634d0815536fd7fca1c1ebcca8668d48b27b 100644
--- a/src/common/caps.py
+++ b/src/common/caps.py
@@ -144,7 +144,7 @@ class CapsCache(object):
 		# prepopulate data which we are sure of; note: we do not log these info
 
 		for account in gajim.connections:
-			gajimcaps = self[('sha-1', gajim.caps_hash[accout])]
+			gajimcaps = self[('sha-1', gajim.caps_hash[account])]
 			gajimcaps.identities = [gajim.gajim_identity]
 			gajimcaps.features = gajim.gajim_common_features + \
 				gajim.gajim_optional_features[account]
diff --git a/src/common/check_paths.py b/src/common/check_paths.py
index 4edca5d7f6ac4eb05be386a8840e4ec1a2a5460e..7ddf6c735ebc558b2f87a621300387835fbc6e2e 100644
--- a/src/common/check_paths.py
+++ b/src/common/check_paths.py
@@ -27,6 +27,7 @@ import os
 import sys
 import stat
 
+import exceptions
 from common import gajim
 import logger
 
diff --git a/src/common/socks5.py b/src/common/socks5.py
index 1523982e64853bb056d3d1105ea2ff2bd3c024e1..1680bf653651adab9ec5459627512582966b1867 100644
--- a/src/common/socks5.py
+++ b/src/common/socks5.py
@@ -31,6 +31,7 @@ from errno import EWOULDBLOCK
 from errno import ENOBUFS
 from errno import EINTR
 from errno import EISCONN
+from errno import EINPROGRESS
 from xmpp.idlequeue import IdleObject
 MAX_BUFF_LEN = 65536
 
@@ -900,10 +901,10 @@ class Socks5Receiver(Socks5, IdleObject):
 				self._sock.setblocking(False)
 				self._server = ai[4]
 				break
-			except Exception:
-				if sys.exc_value[0] == errno.EINPROGRESS:
+			except socket.error, e:
+				if not isinstance(e, basestring) and e[0] == EINPROGRESS:
 					break
-				#for all errors, we try other addresses
+				# for all other errors, we try other addresses
 				continue
 		self.fd = self._sock.fileno()
 		self.state = 0 # about to be connected
diff --git a/src/common/stanza_session.py b/src/common/stanza_session.py
index cb1d7fb7f2774b6b30aeb31dace87a23089893cb..dad5ac58407c2fbf8af018ee76724a624a042e76 100644
--- a/src/common/stanza_session.py
+++ b/src/common/stanza_session.py
@@ -283,7 +283,7 @@ class EncryptedStanzaSession(StanzaSession):
 		return stanza
 
 	def is_xep_200_encrypted(self, msg):
-		msg.getTag('c', namespace=common.xmpp.NS_STANZA_CRYPTO)
+		msg.getTag('c', namespace=xmpp.NS_STANZA_CRYPTO)
 
 	def hmac(self, key, content):
 		return HMAC.new(key, content, self.hash_alg).digest()
diff --git a/src/common/xmpp/auth_nb.py b/src/common/xmpp/auth_nb.py
index 672c6b82d0d7369ba5e83a5e3588a735a18a92c5..f53858a1adc2ea5861ac8e2a31340ea231deed27 100644
--- a/src/common/xmpp/auth_nb.py
+++ b/src/common/xmpp/auth_nb.py
@@ -349,7 +349,7 @@ class NonBlockingNonSASL(PlugIn):
 			self.DEBUG('waiting on handshake', 'notify')
 			return
 		self._owner.onreceive(None)
-		owner._registered_name=self.user
+		self._owner._registered_name=self.user
 		if self.handshake+1: 
 			return self.on_auth('ok')
 		self.on_auth(None)
@@ -448,12 +448,14 @@ class NBComponentBind(ComponentBind):
 	
 	def Bind(self, domain = None, on_bind = None):
 		''' Perform binding. Use provided domain name (if not provided). '''
-		self._owner.onreceive(self._on_bound)
+		def wrapper(resp):
+			self._on_bound(resp, domain)
+		self._owner.onreceive(wrapper)
 		self.on_bind = on_bind
 	
-	def _on_bound(self, resp):
-		if data:
-			self.Dispatcher.ProcessNonBlocking(data)
+	def _on_bound(self, resp, domain=None):
+		if resp:
+			self.Dispatcher.ProcessNonBlocking(resp)
 		if self.bound is None:
 			return
 		self._owner.onreceive(None)
@@ -461,7 +463,7 @@ class NBComponentBind(ComponentBind):
 			Protocol('bind', attrs={'name':domain}, xmlns=NS_COMPONENT_1), 
 			func=self._on_bind_reponse)
 	
-	def _on_bind_reponse(self, res):
+	def _on_bind_reponse(self, resp):
 		if resp and resp.getAttr('error'):
 			self.DEBUG('Binding failed: %s.' % resp.getAttr('error'), 'error')
 		elif resp:
diff --git a/src/common/xmpp/commands.py b/src/common/xmpp/commands.py
index 6e6d3e92e2828ffd595acb4655dc607f4f2a84cf..ed4785e65267d3a0ec08244289a1f2a0860e5d53 100644
--- a/src/common/xmpp/commands.py
+++ b/src/common/xmpp/commands.py
@@ -31,6 +31,7 @@ What it supplies:
     A means of handling requests, by redirection though the command manager.
 """
 
+import math
 from protocol import *
 from client import PlugIn
 
@@ -62,7 +63,7 @@ class Commands(PlugIn):
     def plugout(self):
         """Removes handlers from the session"""
         # unPlug from the session and the disco manager
-        self._owner.UnregisterHandler('iq',self_CommandHandler,ns=NS_COMMANDS)
+        self._owner.UnregisterHandler('iq',self._CommandHandler,ns=NS_COMMANDS)
         for jid in self._handlers:
             self._browser.delDiscoHandler(self._DiscoHandler,node=NS_COMMANDS)
         
@@ -281,10 +282,10 @@ class TestCommand(Command_Handler_Prototype):
             session = None
         if session is None:
             session = self.getSessionID()
-            sessions[session]={'jid':request.getFrom(),'actions':{'cancel':self.cmdCancel,'next':self.cmdSecondStage},'data':{'type':None}}
+            self.sessions[session]={'jid':request.getFrom(),'actions':{'cancel':self.cmdCancel,'next':self.cmdSecondStage},'data':{'type':None}}
         # As this is the first stage we only send a form
         reply = request.buildReply('result')
-        form = DataForm(title='Select type of operation',data=['Use the combobox to select the type of calculation you would like to do, then click Next',DataField(name='calctype',label='Calculation Type',value=sessions[session]['data']['type'],options=[['circlediameter','Calculate the Diameter of a circle'],['circlearea','Calculate the area of a circle']],typ='list-single',required=1)])
+        form = DataForm(title='Select type of operation',data=['Use the combobox to select the type of calculation you would like to do, then click Next',DataField(name='calctype',label='Calculation Type',value=self.sessions[session]['data']['type'],options=[['circlediameter','Calculate the Diameter of a circle'],['circlearea','Calculate the area of a circle']],typ='list-single',required=1)])
         replypayload = [Node('actions',attrs={'execute':'next'},payload=[Node('next')]),form]
         reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':session,'status':'executing'},payload=replypayload)
         self._owner.send(reply)
@@ -312,9 +313,9 @@ class TestCommand(Command_Handler_Prototype):
         except Exception:
             self.cmdSecondStageReply(conn,request)
         if sessions[request.getTagAttr('command','sessionid')]['data']['type'] == 'circlearea':
-            result = num*(pi**2)
+            result = num*(math.pi**2)
         else:
-            result = num*2*pi
+            result = num*2*math.pi
         reply = result.buildReply(request)
         form = DataForm(typ='result',data=[DataField(label='result',name='result',value=result)])
         reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'completed'},payload=form)
@@ -325,8 +326,8 @@ class TestCommand(Command_Handler_Prototype):
         reply = request.buildReply('result')
         reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'cancelled'})
         self._owner.send(reply)
-        del sessions[request.getTagAttr('command','sessionid')]
+        del self.sessions[request.getTagAttr('command','sessionid')]
             
     
 
-# vim: se ts=3:
\ No newline at end of file
+# vim: se ts=3:
diff --git a/src/common/xmpp/session.py b/src/common/xmpp/session.py
index dc7b5f6773140ed38c666e64bf5a6395d9ed9d2f..256de179511b4b243392132be8edf1d6b701dbf0 100644
--- a/src/common/xmpp/session.py
+++ b/src/common/xmpp/session.py
@@ -24,6 +24,8 @@ writing the server.
 
 __version__="$Id"
 
+import random
+import simplexml
 from protocol import *
 
 # Transport-level flags
diff --git a/src/common/xmpp/transports_nb.py b/src/common/xmpp/transports_nb.py
index aac93eeffd15f26c26b777fd81fdcc2104170f23..48166a4d62c5779b8feb4e5c78665ab407fe8a03 100644
--- a/src/common/xmpp/transports_nb.py
+++ b/src/common/xmpp/transports_nb.py
@@ -139,10 +139,10 @@ class SSLWrapper:
 		can indicate that the socket has been closed, so to be sure, we avoid
 		this by returning None. """
 
-		raise NotImplementedException()
+		raise NotImplementedError()
 
 	def send(self, data, flags=None, now = False):
-		raise NotImplementedException()
+		raise NotImplementedError()
 
 class PyOpenSSLWrapper(SSLWrapper):
 	'''Wrapper class for PyOpenSSL's recv() and send() methods'''
diff --git a/src/common/zeroconf/zeroconf.py b/src/common/zeroconf/zeroconf.py
index 6b7c08783754de0811a6803e852360539857bfdb..a99f0390d1e516c3b15c6d129e1d588e12c62f14 100644
--- a/src/common/zeroconf/zeroconf.py
+++ b/src/common/zeroconf/zeroconf.py
@@ -31,8 +31,8 @@ def test_bonjour():
 	try:
 		import pybonjour
 	except ImportError:
-		return False
-	except WindowsError:
+		return False
+	except WindowsError:
 		return False
 	return True
 
@@ -46,4 +46,4 @@ elif test_bonjour():
 	from common.zeroconf import zeroconf_bonjour
 	Zeroconf = zeroconf_bonjour.Zeroconf
 
-# vim: se ts=3:
\ No newline at end of file
+# vim: se ts=3:
diff --git a/src/common/zeroconf/zeroconf_bonjour.py b/src/common/zeroconf/zeroconf_bonjour.py
index fb8eba701f884d796620bc4af66a602912dc297b..80c985215140ad5579958317718f6aa8092ee77a 100644
--- a/src/common/zeroconf/zeroconf_bonjour.py
+++ b/src/common/zeroconf/zeroconf_bonjour.py
@@ -251,7 +251,7 @@ class Zeroconf:
 			self.announced = False
 			return True
 		except pybonjour.BonjourError, e:
-			geajim.log.debug(e)
+			gajim.log.debug(e)
 			return False
 
 
diff --git a/src/config.py b/src/config.py
index 50bbdbaab336c773407fbe1dc91a279504b66e99..68baa884e8c0b523d193430ec2953c44fab9b685 100644
--- a/src/config.py
+++ b/src/config.py
@@ -57,6 +57,7 @@ from common import connection
 from common import passwords
 from common import zeroconf
 from common import dataforms
+from common import GnuPG
 
 from common.exceptions import GajimGeneralException
 
diff --git a/src/gtkexcepthook.py b/src/gtkexcepthook.py
index 4719f520de3564acc46d5cf53c4c9176a693eaad..e75793251851bc5932a283997473eafed75f1db5 100644
--- a/src/gtkexcepthook.py
+++ b/src/gtkexcepthook.py
@@ -104,6 +104,6 @@ if os.name == 'nt' or not sys.stderr.isatty():
 if __name__ == '__main__':
 	_excepthook_save = sys.excepthook
 	sys.excepthook = _info
-	print x # this always tracebacks
+	raise Exception()
 
 # vim: se ts=3:
diff --git a/src/osx/syncmenu/setup.py b/src/osx/syncmenu/setup.py
index 3e0fc65615b1bb0ed5a5f26db1789fa8cae89ba7..bac7572f0550ed5015135e1becf4bcb221c5d554 100644
--- a/src/osx/syncmenu/setup.py
+++ b/src/osx/syncmenu/setup.py
@@ -1,3 +1,4 @@
+import sys
 from distutils.core import setup, Extension
 import commands
 
@@ -26,4 +27,4 @@ setup(name='syncmenu', version='0.2',
 				  extra_compile_args=['-Wall'] + cflags)
       ])
 
-# vim: se ts=3:
\ No newline at end of file
+# vim: se ts=3:
diff --git a/src/remote_control.py b/src/remote_control.py
index ec7054a93286fd3d946715fb8123bb6674927aa8..1af7b761561d558fd978854d6998598449ffa273 100644
--- a/src/remote_control.py
+++ b/src/remote_control.py
@@ -327,7 +327,7 @@ class SignalObject(dbus.service.Object):
 		'''Shows the tabbed window for new message to 'jid', using account
 		(optional) 'account' '''
 		if not jid:
-			raise MissingArgument
+			raise dbus_support.MissingArgument()
 		jid = self._get_real_jid(jid, account)
 		try:
 			jid = helpers.parse_jid(jid)
@@ -407,7 +407,7 @@ class SignalObject(dbus.service.Object):
 		if not isinstance(jid, unicode):
 			jid = unicode(jid)
 		if not jid:
-			raise MissingArgument
+			raise dbus_support.MissingArgument()
 		jid = self._get_real_jid(jid)
 
 		cached_vcard = gajim.connections.values()[0].get_cached_vcard(jid)
diff --git a/src/secrets.py b/src/secrets.py
index 28a9fb91629367a9b6098815845f046a6a15dee8..d258bc66039cddecaf2376b8e210c984ee7a6a73 100644
--- a/src/secrets.py
+++ b/src/secrets.py
@@ -21,6 +21,7 @@
 
 from common.configpaths import gajimpaths
 
+import Crypto
 from common import crypto
 from common import exceptions