make python 2 and 3 work at once (and some whitespace tidying)
make doctests work with python3 too