Migrated to Python3 and minor bugfixes