python 3 conversion and random tweaks