Added some compatibility with python3