Fixing Python3-incompatible code