Fixed some runtime errors with Python 3