added some keepalive handling