port to python3
misc bugfixes, many of them unicode related