Changed some code to provide support for python 2.6.