various minor fixes in gateway initialization
manage https re-handshake and fix gevent timeout management