Towards a Python 3 compatible version (altough gevent still isn't anyway...)