Fixed Python 2-to-3 transition-specific bugs