Fix race conditions in onReceiveCallback and cachedPeers