Python 3 compatibility (still needs some love)