Switched to Python3. Some bugfixes