 class NotificationService: UNNotificationServiceExtension {
     
     /// Content handlers. Keys are eventId's
-    var contentHandlers: [String: ((UNNotificationContent) -> Void)] = [:]
+    private var contentHandlers: [String: ((UNNotificationContent) -> Void)] = [:]
+    
+    private var userAccount: MXKAccount?
     
     /// Best attempt contents. Will be updated incrementally, if something fails during the process, this best attempt content will be showed as notification. Keys are eventId's
-    var bestAttemptContents: [String: UNMutableNotificationContent] = [:]
-    
-    /// Cached events. Keys are eventId's
-    var cachedEvents: [String: MXEvent] = [:]
-    static var mxSession: MXSession?
-    static var syncResponseStore: SyncResponseStore?
-    var showDecryptedContentInNotifications: Bool {
+    private var bestAttemptContents: [String: UNMutableNotificationContent] = [:]
+    
+    private static var backgroundSyncService: MXBackgroundSyncService!
+    private var showDecryptedContentInNotifications: Bool {
         return RiotSettings.shared.showDecryptedContentInNotifications
     }
-    lazy var configuration: Configurable = {
+    private lazy var configuration: Configurable = {
         return CommonConfiguration()
     }()
-    static var isLoggerInitialized: Bool = false
+    private static var isLoggerInitialized: Bool = false
     private lazy var pushGatewayRestClient: MXPushGatewayRestClient = {
         let url = URL(string: BuildSettings.serverConfigSygnalAPIUrlString)!
         return MXPushGatewayRestClient(pushGateway: url.scheme! + "://" + url.host!, andOnUnrecognizedCertificateBlock: nil)

    }
    
}

extension MXRoom {
    
    func getRoomPushRule() -> MXPushRule? {
        guard let rules = self.mxSession.notificationCenter.rules.global.room else {
            return nil
        }
        
        for rule in rules {
            guard let pushRule = rule as? MXPushRule else { continue }
            // the rule id is the room Id
            // it is the server trick to avoid duplicated rule on the same room.
            if pushRule.ruleId == self.roomId {
                return pushRule
            }
        }

        return nil
    }

    var isMentionsOnly: Bool {
        // Check push rules at room level
        guard let rule = self.getRoomPushRule() else {
            return false
        }
        
        for ruleAction in rule.actions {
            guard let action = ruleAction as? MXPushRuleAction else { continue }
            if action.actionType == MXPushRuleActionTypeDontNotify {
                return rule.enabled
            }
        }

        return false
    }
    
}

        }
    }
    
    private func fallbackToBestAttemptContent(forEventId eventId: String) {
        NSLog("[NotificationService] fallbackToBestAttemptContent: method called.")
        
        guard let content = bestAttemptContents[eventId] else {
