Improving python 2.x compatibility

There seems to be leaking memory in python 2.x whenever you do a connect/close. I believe that this fixes the problem.