Gevent optimization