Fixes for python3 compatibility.