Fixed some Python 3 compat issues