Changes for python3 compatibility