     func addDelegate(_ delegate: RankingManagerDelegate, for liveId: String) {
         objc_sync_enter(self)
         defer { objc_sync_exit(self) }
-        delegates[liveId] = WeakDelegateReference(delegate: delegate)
+        // De-register the delegate before registering, just in case.
+        delegates = delegates.filter { $0.1.delegate !== delegate }
+        delegates.append((liveId, WeakDelegateReference(delegate: delegate)))
         logDelegates()
         scheduleQueryTimerIfNeeded()
         // Just in case, notify rank immediately with latest rank map.


    var isRunning: Bool { queryTimer != nil && queryTimer?.isValid == true }

    // Key: [liveId] -> Value: [weak reference to delegate object]
    private var delegates: [String: WeakDelegateReference] = [:]
    // Key: [liveId] -> Value: [ranking value]
    private var rankMap: [String: Int] = [:]
    private var queryTimer: Timer?

    func removeDelegate(_ delegate: RankingManagerDelegate) {
        objc_sync_enter(self)
        defer { objc_sync_exit(self) }
        delegates = delegates.filter { $0.1.delegate !== delegate }
        logDelegates()
        invalidateQueryTimerIfNeeded()
    }
