Migrate to Py3. Some bugfixes.