         super.viewWillDisappear(animated)
     }
     
+    deinit {
+        removeScriptMessageHandlers()
+    }
+    
     @objc func keyboardDidHide() {
         inputViewsController.resetFormattingAndStyleSubmenus()
     }

        }
        
        contentController.addUserScript(setupUserScript)
        contentController.add(setupUserScript, name: setupUserScript.messageHandlerName)
        
        contentController.add(messagingController, name: SectionEditorWebViewMessagingController.Message.Name.codeMirrorMessage)
        contentController.add(messagingController, name: SectionEditorWebViewMessagingController.Message.Name.codeMirrorSearchMessage)

        contentController.add(messagingController, name: SectionEditorWebViewMessagingController.Message.Name.smoothScrollToYOffsetMessage)
        contentController.add(messagingController, name: SectionEditorWebViewMessagingController.Message.Name.replaceAllCountMessage)
        
        contentController.add(messagingController, name: SectionEditorWebViewMessagingController.Message.Name.didSetWikitextMessage)
        
        configuration.userContentController = contentController
        webView = SectionEditorWebView(frame: .zero, configuration: configuration)

        webViewTopConstraint.constant = 0
        focusNavigationView.isHidden = true
        navigationController?.setNavigationBarHidden(false, animated: false)
    }
    
    private func removeScriptMessageHandlers() {
        
        guard let userContentController = webView?.configuration.userContentController,
            !scriptMessageHandlers.isEmpty else {
                return
        }
        
        for handler in scriptMessageHandlers {
            userContentController.removeScriptMessageHandler(forName: handler.name)
        }
        
        scriptMessageHandlers.removeAll()
    }
    
    private func addScriptMessageHandlers(to contentController: WKUserContentController) {
        
        guard !scriptMessageHandlers.isEmpty else {
            return
        }
        
        for handler in scriptMessageHandlers {
            contentController.add(handler.handler, name: handler.name)
        }
    }
    
    private func configureWebView() {
