             peer.dnsService = nil
             peer.state = .notConnected
             peer.announced = false
-        }
-        self.killAllKeepaliveTimers()
+            peer.keepaliveTimer?.invalidate()
+            peer.keepaliveTimer = nil
+        }
         self.peers = [] // remove all peers!
     }
     

    
    public func socket(_ sock: GCDAsyncSocket, didConnectToHost host: String, port: UInt16) {
        guard let peer = sock.peer else {
            assert(false, "BluepeerObject: programming error, expected to find a peer already in didConnectToHost")
            return
        }
        peer.state = .awaitingAuth

    
    public func socket(_ sock: GCDAsyncSocket, didWritePartialDataOfLength partialLength: UInt, tag: Int) {
        guard let peer = sock.peer else {
            return
        }
        self.scheduleNextKeepaliveTimer(peer)
