Some more refactorings.
Fixed a bug with Python 2.5