Fixed python compatibility issues