adding py2.4 compatibility and removed not used imports