Added support for python 3; small adpatations.