works in python3
more fixes for python3 support
more bug fixes