 README        |   19 +++---
 doc/LICENSE   |  197 +++++---------------------------------------------------
 msn           |   18 +++---
 msncb.py      |   34 +++++++++--
 msnlib.py     |   39 +++++++++---
 setup.py      |    2 +-
 utils/msnbot  |    2 +-
 utils/msncd   |   12 ++--
 utils/msnsbot |    2 +-
 utils/msntk   |    4 +-
 10 files changed, 106 insertions(+), 223 deletions(-)

diff --git a/README b/README
index 746a6cf..a986b33 100644
--- a/README
+++ b/README
@@ -3,22 +3,23 @@ msnlib
 Alberto Bertogli (albertito@blitiri.com.ar)
 ----------------------------------------------
 
-This is a python implementation for the msn messenger protocol (version 8),
-it's pretty simple and straightforward; but it works well.
+This is a python implementation for the msn messenger protocol (version 8);
+it's pretty simple and straightforward, but it works well.
 
 Please read the 'INSTALL' file to see how to install and use both the client
 and the library.
 
 The client is really simple, uses a text-mode interface with commands similar
-to 'micq' (http://micq.ukeer.de/), which is a great ICQ client.
+to 'climm' (formerly 'micq', http://www.climm.org/), which is a great ICQ
+client.
 
-If you're looking for a good messaging system, forget about messenger and try
-Jabber (http://www.jabber.org), it's the only one which is run in the open
-based on public standards, it's safe, fast, has a lot of features and it's
-quite scalable.
+If you're looking for a good messaging system, forget about MSN and try Jabber
+(http://www.jabber.org), it's the only one which is run in the open based on
+public standards, it's safe, fast, has a lot of features and it's quite
+scalable.
 
-But if you're stuck with messenger for whatever reason (your friends,
-family, the dog, all use it =), I hope you find this useful.
+But if you're stuck with messenger for whatever reason, I hope you find this
+useful.
 
 
 The basic idea for the library is a main class which represents a connection
diff --git a/doc/LICENSE b/doc/LICENSE
index bdf1e48..a9dc71f 100644
--- a/doc/LICENSE
+++ b/doc/LICENSE
@@ -1,186 +1,25 @@
 
-This project, 'msnlib', is copyrighted by Alberto Bertogli and licensed under
-the Open Software License version 2.0 as obtained from www.opensource.org (and
-included here-in for easy reference) (that license itself is copyrighted by
-Larry Rosen).
+msnlib is licensed under the MIT license, as reproduced below.
 
-Note that the "Original Work" that this license covers is only the library
-itself and the client, along with the sample callbacks. Thus just the act of
-linking/importing this library into another program does NOT in itself make
-that program considered a derivative work of this Original Work.
+--------
 
-		Alberto Bertogli
-		20 May 2003
+Copyright (c) 2011 Alberto Bertogli
 
--------------------------------------------------------------------------
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
 
-Open Software License
- v. 2.0
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
 
-This Open Software License (the "License") applies to any original work of
-authorship (the "Original Work") whose owner (the "Licensor") has placed the
-following notice immediately following the copyright notice for the Original
-Work:
-
-	Licensed under the Open Software License version 2.0
-
-
-1) Grant of Copyright License. Licensor hereby grants You a world-wide,
-royalty-free, non-exclusive, perpetual, sublicenseable license to do the
-following:
-
-  a) to reproduce the Original Work in copies;
-
-  b) to prepare derivative works ("Derivative Works") based upon the
-     Original Work;
-
-  c) to distribute copies of the Original Work and Derivative Works to
-     the public, with the proviso that copies of Original Work or
-     Derivative Works that You distribute shall be licensed under the
-     Open Software License;
-
-  d) to perform the Original Work publicly; and
-
-  e) to display the Original Work publicly.
-
-2) Grant of Patent License. Licensor hereby grants You a world-wide,
-royalty-free, non-exclusive, perpetual, sublicenseable license, under patent
-claims owned or controlled by the Licensor that are embodied in the Original
-Work as furnished by the Licensor, to make, use, sell and offer for sale the
-Original Work and Derivative Works.
-
-3) Grant of Source Code License. The term "Source Code" means the preferred
-form of the Original Work for making modifications to it and all available
-documentation describing how to modify the Original Work. Licensor hereby
-agrees to provide a machine-readable copy of the Source Code of the Original
-Work along with each copy of the Original Work that Licensor distributes.
-Licensor reserves the right to satisfy this obligation by placing a
-machine-readable copy of the Source Code in an information repository
-reasonably calculated to permit inexpensive and convenient access by You for
-as long as Licensor continues to distribute the Original Work, and by
-publishing the address of that information repository in a notice immediately
-following the copyright notice that applies to the Original Work.
-
-4) Exclusions From License Grant. Neither the names of Licensor, nor the names
-of any contributors to the Original Work, nor any of their trademarks or
-service marks, may be used to endorse or promote products derived from this
-Original Work without express prior written permission of the Licensor.
-Nothing in this License shall be deemed to grant any rights to trademarks,
-copyrights, patents, trade secrets or any other intellectual property of
-Licensor except as expressly stated herein. No patent license is granted to
-make, use, sell or offer to sell embodiments of any patent claims other than
-the licensed claims defined in Section 2. No right is granted to the
-trademarks of Licensor even if such marks are included in the Original Work.
-Nothing in this License shall be interpreted to prohibit Licensor from
-licensing under different terms from this License any Original Work that
-Licensor otherwise would have a right to license.
-
-5) External Deployment. The term "External Deployment" means the use or
-distribution of the Original Work or Derivative Works in any way such that the
-Original Work or Derivative Works may be used by anyone other than You,
-whether the Original Work or Derivative Works are distributed to those persons
-or made available as an application intended for use over a computer network.
-As an express condition for the grants of license hereunder, You agree that
-any External Deployment by You of a Derivative Work shall be deemed a
-distribution and shall be licensed to all under the terms of this License, as
-prescribed in section 1(c) herein.
-
-6) Attribution Rights. You must retain, in the Source Code of any Derivative
-Works that You create, all copyright, patent or trademark notices from the
-Source Code of the Original Work, as well as any notices of licensing and any
-descriptive text identified therein as an "Attribution Notice." You must cause
-the Source Code for any Derivative Works that You create to carry a prominent
-Attribution Notice reasonably calculated to inform recipients that You have
-modified the Original Work. 
-
-7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that
-the copyright in and to the Original Work and the patent rights granted herein
-by Licensor are owned by the Licensor or are sublicensed to You under the
-terms of this License with the permission of the contributor(s) of those
-copyrights and patent rights. Except as expressly stated in the immediately
-proceeding sentence, the Original Work is provided under this License on an
-"AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including,
-without limitation, the warranties of NON-INFRINGEMENT, MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE
-ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an
-essential part of this License. No license to Original Work is granted
-hereunder except under this disclaimer. 
-
-8) Limitation of Liability. Under no circumstances and under no legal theory,
-whether in tort (including negligence), contract, or otherwise, shall the
-Licensor be liable to any person for any direct, indirect, special,
-incidental, or consequential damages of any character arising as a result of
-this License or the use of the Original Work including, without limitation,
-damages for loss of goodwill, work stoppage, computer failure or malfunction,
-or any and all other commercial damages or losses. This limitation of
-liability shall not apply to liability for death or personal injury resulting
-from Licensor's negligence to the extent applicable law prohibits such
-limitation. Some jurisdictions do not allow the exclusion or limitation of
-incidental or consequential damages, so this exclusion and limitation may not
-apply to You. 
-
-9) Acceptance and Termination. If You distribute copies of the Original Work
-or a Derivative Work, You must make a reasonable effort under the
-circumstances to obtain the express assent of recipients to the terms of this
-License. Nothing else but this License (or another written agreement between
-Licensor and You) grants You permission to create Derivative Works based upon
-the Original Work or to exercise any of the rights granted in Section 1
-herein, and any attempt to do so except under the terms of this License (or
-another written agreement between Licensor and You) is expressly prohibited by
-U.S.  copyright law, the equivalent laws of other countries, and by
-international treaty. Therefore, by exercising any of the rights granted to
-You in Section 1 herein, You indicate Your acceptance of this License and all
-of its terms and conditions. This License shall terminate immediately and you
-may no longer exercise any of the rights granted to You by this License upon
-Your failure to honor the proviso in Section 1(c) herein.
-
-10) Termination for Patent Action. This License shall terminate automatically
-and You may no longer exercise any of the rights granted to You by this
-License as of the date You commence an action, including a cross-claim or
-counterclaim, for patent infringement (i) against Licensor with respect to a
-patent applicable to software or (ii) against any entity with respect to a
-patent applicable to the Original Work (but excluding combinations of the
-Original Work with other software or hardware).
-
-11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this
-License may be brought only in the courts of a jurisdiction wherein the
-Licensor resides or in which Licensor conducts its primary business, and under
-the laws of that jurisdiction excluding its conflict-of-law provisions. The
-application of the United Nations Convention on Contracts for the
-International Sale of Goods is expressly excluded. Any use of the Original
-Work outside the scope of this License or after its termination shall be
-subject to the requirements and penalties of the U.S. Copyright Act, 17 U.S.C.
-101 et seq., the equivalent laws of other countries, and international treaty.
-This section shall survive the termination of this License.
-
-12) Attorneys Fees. In any action to enforce the terms of this License or
-seeking damages relating thereto, the prevailing party shall be entitled to
-recover its costs and expenses, including, without limitation, reasonable
-attorneys' fees and costs incurred in connection with such action, including
-any appeal of such action. This section shall survive the termination of this
-License.
-
-13) Miscellaneous. This License represents the complete agreement concerning
-the subject matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent necessary
-to make it enforceable.
-
-14) Definition of "You" in This License. "You" throughout this License,
-whether in upper or lower case, means an individual or a legal entity
-exercising rights under, and complying with all of the terms of, this License.
-For legal entities, "You" includes any entity that controls, is controlled by,
-or is under common control with you. For purposes of this definition,
-"control" means (i) the power, direct or indirect, to cause the direction or
-management of such entity, whether by contract or otherwise, or (ii) ownership
-of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
-ownership of such entity.
-
-15) Right to Use. You may use the Original Work in all ways not otherwise
-restricted or conditioned by this License or by law, and Licensor promises not
-to interfere with or be responsible for such uses by You.
-
-This license is Copyright (C) 2003 Lawrence E. Rosen. All rights reserved.
-Permission is hereby granted to copy and distribute this license without
-modification. This license may not be modified without the express written
-permission of its copyright owner.
diff --git a/msn b/msn
index 85d8ef7..2f50535 100755
--- a/msn
+++ b/msn
@@ -563,7 +563,7 @@ try:
 	newtermattr = termios.tcgetattr(stdinfd)
 	newtermattr[3] = newtermattr[3] & ~termios.ICANON & ~termios.ECHO
 	termios.tcsetattr(stdinfd, termios.TCSANOW, newtermattr)
-	import fcntl, os
+	import fcntl
 	fcntl.fcntl(stdinfd, fcntl.F_SETFL, os.O_NONBLOCK)
 	del(newtermattr)
 	use_termios = 1
@@ -1635,7 +1635,7 @@ m.cb.reg = cb_reg
 #
 # now the real thing
 #
-printl('* MSN Client (3.7) *\n', c.yellow, 1)
+printl('* MSN Client (3.8) *\n', c.yellow, 1)
 
 # first, the configuration
 printl('Loading config... ', c.green, 1)
@@ -1660,7 +1660,7 @@ config['profile'] = profile
 
 # set the mandatory values
 if config.has_key('email'):
-	m.email = config['email']
+	m.email = config['email'].lower()
 else:
 	perror('Error: email not specified in config file\n')
 	quit(1)
@@ -1695,7 +1695,7 @@ else:
 	try:
 		config['history size'] = int(config['history size'])
 	except:
-		error('input history size must be integer, using default\n')
+		perror('input history size must be integer, using default\n')
 		config['input history size'] = 10
 
 # initial status
@@ -1776,7 +1776,7 @@ printl('Logging in... ', c.green, 1)
 try:
 	m.login()
 	printl('done\n', c.green, 1)
-except 'AuthError', info:
+except msnlib.AuthError, info:
 	errno = int(info[0])
 	if not msncb.error_table.has_key(errno):
 		desc = 'Unknown'
@@ -1786,7 +1786,7 @@ except 'AuthError', info:
 	quit(1)
 except KeyboardInterrupt:
 	quit()
-except ('SocketError', socket.error), info:
+except (msnlib.SocketError, socket.error), info:
 	perror('Network error: ' + str(info) + '\n')
 	quit(1)
 except:
@@ -1859,9 +1859,7 @@ while 1:
 					else:
 						perror('\rError setting status: unknown status %s\n' % config['initial status'])
 
-
-
-			except ('SocketError', socket.error), err:
+			except (msnlib.SocketError, socket.error), err:
 				if i != m:
 					if i.msgqueue:
 						nick = email2nick(i.emails[0])
@@ -1872,7 +1870,7 @@ while 1:
 				else:
 					printl('\nMain socket closed (%s)\n' % str(err), c.red)
 					quit(1)
-			except 'XFRError', err:
+			except msncb.XFRError, err:
 				printl("\rXFR Error: %s\n" % str(err))
 
 			# always redraw after network event
diff --git a/msncb.py b/msncb.py
index 1638335..c2b73bd 100644
--- a/msncb.py
+++ b/msncb.py
@@ -1,6 +1,5 @@
 
 
-import string
 import urllib
 import socket
 
@@ -8,7 +7,7 @@ import socket
 # introduced in python 2.5
 try:
 	from hashlib import md5
-except:
+except ImportError:
 	from md5 import md5
 
 import msnlib
@@ -77,6 +76,7 @@ class cb:
 		self.ack = cb_ack	# message acknowledge
 		self.nak = cb_nak	# message negative acknowledge
 		self.bye = cb_bye	# switchboard user disconnect
+		self.qng = cb_qng	# pong!
 
 
 
@@ -120,6 +120,25 @@ error_table = {
 	920: 'Not accepting new users',
 }
 
+
+#
+# Possible exceptions
+#
+
+class CallbackMess (Exception):
+	pass
+
+class SYNError (Exception):
+	pass
+
+class XFRError (Exception):
+	pass
+
+
+#
+# Callbacks
+#
+
 def cb_err(md, errno, params):
 	"Handle server errors"
 	if not error_table.has_key(errno):
@@ -143,7 +162,8 @@ def cb_unk(md, type, tid, params):
 
 def cb_chl(md, type, tid, params):
 	"Handles the challenges"
-	if type != 'CHL': raise 'CallbackMess', (md, type, params)
+	if type != 'CHL':
+		raise CallbackMess, (md, type, params)
 	hash = params + 'VT6PX?UQTM4WM%YR' # magic from www.hypothetic.org
 	hash = md5(hash).hexdigest()
 	md._send('QRY', 'PROD0038W!61ZTF9 32')
@@ -225,7 +245,7 @@ def cb_syn(md, type, tid, params):
 	"Receive a SYN notification"
 	t = params.split()
 	if len(t) != 3:
-		raise "SYNError"
+		raise SYNError
 
 	lver = int(t[0])
 	total = int(t[1])
@@ -430,7 +450,7 @@ def cb_xfr(md, type, tid, params):
 			break
 	if not sbd:
 		debug('AIEEE: XFR without sbd!')
-		raise 'XFRError', (type, tid, params)
+		raise XFRError, (type, tid, params)
 
 	sbd.fd = fd
 	sbd.block = 0
@@ -512,3 +532,7 @@ def cb_bye(md, type, tid, params, sbd):
 		debug('BYE: closing %s' % str(sbd))
 		md.close(sbd)
 
+def cb_qng(md, type, tid, params):
+	"Get the response of a ping"
+	debug('PONG!: answered by the server')
+
diff --git a/msnlib.py b/msnlib.py
index 9d9952e..391af13 100644
--- a/msnlib.py
+++ b/msnlib.py
@@ -11,7 +11,7 @@ by Alberto Bertogli (albertito@blitiri.com.ar)
 """
 
 # constants
-VERSION = 0x0307
+VERSION = 0x0308
 LOGIN_HOST = 'messenger.hotmail.com'
 LOGIN_PORT = 1863
 
@@ -40,6 +40,21 @@ reverse_status = {
 }
 
 
+# Possible exceptions
+class SocketError (Exception):
+	pass
+
+class VersionError (Exception):
+	pass
+
+class NSError (Exception):
+	pass
+
+class AuthError (Exception):
+	pass
+
+
+
 def debug(s):
 	sys.stderr.write('\r' + str(s) + '\n')
 	sys.stderr.flush()
@@ -280,7 +295,7 @@ class msnd:
 			c = fd.recv(1)
 
 		if c == '':
-			raise 'SocketError'
+			raise SocketError
 
 		buf = buf.strip()
 		pbuf = buf.split(' ')
@@ -440,6 +455,10 @@ class msnd:
 			pass
 		del(sb)
 
+	def ping(self):
+		"Sends a ping to the server"
+		try: self.fd.send('PNG\r\n')
+		except: pass
 
 	def invite(self, email, sbd):
 		"Invites a user into an existing sbd"
@@ -457,7 +476,7 @@ class msnd:
 
 		r = self._recv()
 		if r[0] != 'VER' and r[2][0:4] != 'MSNP8':
-			raise 'VersionError', r
+			raise VersionError, r
 
 		# lie the version, just in case
 		self._send('CVR', '0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS ' + self.email)
@@ -468,7 +487,7 @@ class msnd:
 
 		r = self._recv()
 		if r[0] != 'XFR' and r[2][0:2] != 'NS':
-			raise 'NSError', r
+			raise NSError, r
 
 		# parse the notification server ip and port (as int)
 		ns = string.split(r[2])[1]
@@ -485,7 +504,7 @@ class msnd:
 		self._send('VER', 'MSNP8 CVR0')
 		r = self._recv()
 		if r[0] != 'VER' and r[2][0:4] != 'MSNP8':
-			raise 'VersionError', r
+			raise VersionError, r
 
 		# lie the version, just in case
 		self._send('CVR', '0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS	' + self.email)
@@ -496,7 +515,7 @@ class msnd:
 
 		r = self._recv()
 		if r[0] != 'USR':
-			raise 'AuthError', r
+			raise AuthError, r
 		hash = string.split(r[2])[2]
 
 		# get and use the passport id
@@ -505,7 +524,7 @@ class msnd:
 
 		r = self._recv()
 		if r[0] != 'USR' and r[2][0:2] != 'OK':
-			raise 'AuthError', r
+			raise AuthError, r
 		self.nick = string.split(r[2])[2]
 		self.nick = urllib.unquote(self.nick)
 
@@ -572,7 +591,7 @@ class msnd:
 			# for now we raise 911, which means authentication
 			# failed; but maybe we can get more detailed
 			# information
-			raise 'AuthError', [911, 'SSL Auth failed']
+			raise AuthError, (911, 'SSL Auth failed')
 
 		# and parse the headers to get the passport id
 		try:
@@ -606,7 +625,7 @@ class msnd:
 				r = nd.fd.getsockopt(socket.SOL_SOCKET,
 					socket.SO_ERROR)
 				if r != 0:
-					raise 'SocketError', 'ConnectFailed'
+					raise SocketError, 'Connect failed'
 				nd.fd.setblocking(1)
 				nd.block = 1
 				nd.state = 're'
@@ -664,6 +683,8 @@ class msnd:
 		elif type == 'NAK': self.cb.nak(self, type, tid, params, nd)
 		elif type == 'BYE': self.cb.bye(self, type, tid, params, nd)
 
+		elif type == 'QNG': self.cb.qng(self, type, tid, params)
+
 		elif type == 'MSG':
 			params = tid + ' ' + params
 			mlen = int(r[2].split()[-1])
diff --git a/setup.py b/setup.py
index 4ced0d1..ea8f892 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@
 from distutils.core import setup
 
 setup(name="msnlib",
-	version="3.7",
+	version="3.8",
 	description="MSN Messenger Library and Client",
 	author="Alberto Bertogli",
 	author_email="albertogli@blitiri.com.ar",
diff --git a/utils/msnbot b/utils/msnbot
index cd20735..2f6f309 100755
--- a/utils/msnbot
+++ b/utils/msnbot
@@ -111,7 +111,7 @@ while 1:
 	for i in fds[0] + fds[1]:       # see msnlib.msnd.pollable.__doc__
 		try:
 			m.read(i)
-		except ('SocketError', socket.error), err:
+		except (msnlib.SocketError, socket.error), err:
 			if i != m:
 				# user closed a connection
 				# note that messages can be lost here
diff --git a/utils/msncd b/utils/msncd
index 82a7e7e..7aabf56 100755
--- a/utils/msncd
+++ b/utils/msncd
@@ -161,7 +161,7 @@ def login(email, password):
 	try:
 		m.login()
 		printl('done\n', c.green, 1)
-	except 'AuthError', info:
+	except msnlib.AuthError, info:
 		errno = int(info[0])
 		if not msncb.error_table.has_key(errno):
 			desc = 'Unknown'
@@ -171,7 +171,7 @@ def login(email, password):
 		quit(1)
 	except KeyboardInterrupt:
 		quit()
-	except ('SocketError', socket.error), info:
+	except (msnlib.SocketError, socket.error), info:
 		perror('Network error: ' + str(info) + '\n')
 		quit(1)
 	except:
@@ -216,7 +216,7 @@ def pipe_read(c):
 	except:
 		psend(c, 'ERR EINVAL\n')
 		return
-	
+
 	if cmd == 'LOGIN':
 		if len(params) != 2:
 			psend(c, 'ERR PARAMS\n')
@@ -227,7 +227,7 @@ def pipe_read(c):
 			m.pwd = pwd
 			m.login()
 			m.sync()
-		except 'AuthError', info:
+		except msnlib.AuthError, info:
 			errno = int(info[0])
 			if not msncb.error_table.has_key(errno):
 				desc = 'Unknown'
@@ -235,7 +235,7 @@ def pipe_read(c):
 				desc = msncb.error_table[errno]
 			psend(c, 'ERR MSN %d %s\n' % (errno, desc))
 			return
-		except ('SocketError', socket.error), info:
+		except (msnlib.SocketError, socket.error), info:
 			psend(c, 'ERR SOCK %s\n' % str(info))
 			return
 		psend(c, 'OK\n')
@@ -401,7 +401,7 @@ while 1:
 		else:
 			try:
 				m.read(i)
-			except ('SocketError', socket.error), err:
+			except (msnlib.SocketError, socket.error), err:
 				if i != m:
 					# user closed a connection
 					# note that messages can be
diff --git a/utils/msnsbot b/utils/msnsbot
index 8e790a1..aaf839f 100755
--- a/utils/msnsbot
+++ b/utils/msnsbot
@@ -136,7 +136,7 @@ class bot:
 			for i in fds[0] + fds[1]:
 				try:
 					self.m.read(i)
-				except ('SocketError', socket.error), err:
+				except (msnlib.SocketError, socket.error), err:
 					traceback.print_last()
 					if i != self.m:
 						# the user closed a connection
diff --git a/utils/msntk b/utils/msntk
index cd6bb36..dd15e4c 100755
--- a/utils/msntk
+++ b/utils/msntk
@@ -423,7 +423,7 @@ root.update()
 try:
 	m.login()
 	m.sync()
-except 'AuthError':
+except msnlib.AuthError:
 	tkMessageBox.showerror("Login", "Error logging in: wrong password")
 	quit()
 
@@ -449,7 +449,7 @@ while 1:
 	for i in fds[0] + fds[1]:
 		try:
 			m.read(i)
-		except ('SocketError', socket.error), err:
+		except (msnlib.SocketError, socket.error), err:
 			if i != m:
 				m.close(i)
 			else:

