python3/pypy compatibility fix + removing obsolete code