         for insertion in insertions {
             guard
                 insertion < messagesQuery.count,
-                let message = messagesQuery[insertion].validated()
+                let message = messagesQuery[insertion].validated()?.unmanaged
             else {
                 continue
             }

                if let object = section.object.base as? MessageSectionModel {
                    return
                        object.differenceIdentifier == message.identifier &&
                            !message.isContentEqual(to: object.message)
                }

                return false
            })

            if let index = index {
                var previous: AnyChatSection?

                if index < data.count - 1 {
                    previous = data[index + 1]
                }

                if let newSection = section(for: message.managedObject, previous: previous) {
                    data[index] = newSection
                }
            } else {

    func fetchMessages(from oldestMessage: Date?) {
        guard !requestingData, hasMoreData else { return }
        guard let subscription = subscription?.validated() else { return }
        guard let subscriptionUnmanaged = subscription.unmanaged else { return }

        let messagesFromDatabase = subscription.fetchMessages(30, lastMessageDate: oldestMessage)
        messagesFromDatabase.forEach {
            guard
                let message = $0.validated()?.unmanaged,
                let section = section(for: message)
            else {
                return
            }

            data.append(section)
        }

        if messagesFromDatabase.count > 0 {
            cacheDataSorted()
            onDataChanged?()
        }

        requestingData = true
        MessageManager.getHistory(subscriptionUnmanaged, lastMessageDate: oldestMessage) { [weak self] oldest in
            DispatchQueue.main.async {
                self?.requestingData = false
                self?.hasMoreData = oldest != nil
