Further Python 3 compatiblity fixes