Cleaned up the Python 2/3 compat code