Some work on python3 compatibility