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

            NSLog("BluepeerObject: didEnterBackground - stopped browsing & advertising, and disconnected session")
        } else {
            NSLog("BluepeerObject: didEnterBackground - stopped browsing & advertising")
        }
    }
    
    func willEnterForeground() {

    
    public func socket(_ sock: GCDAsyncSocket, didRead data: Data, withTag tag: Int) {
        guard let peer = sock.peer else {
            NSLog("BluepeerObject: WARNING, did not find peer in didReadData, doing nothing")
            return
        }
        self.scheduleNextKeepaliveTimer(peer)
