         }
     }
     
+    /// Perform any necessary initial configuration for state restoration
+    func setupForStateRestorationIfNecessary() {
+        guard isRestoringState else {
+            return
+        }
+        setWebViewHidden(true, animated: false)
+    }
+    
+    /// If state needs to be restored, listen for content size changes and restore the scroll position when those changes stop occurring
     func restoreStateIfNecessary() {
         guard isRestoringState else {
             return
         }
-        setWebViewHidden(true, animated: false)
         isRestoringState = false
         isRestoringStateOnNextContentSizeChange = true
         perform(#selector(restoreState), with: nil, afterDelay: 0.5) // failsafe, attempt to restore state after half a second regardless
     }
     
+    /// If state is supposed to be restored after the next content size change, restore that state
+    /// This should be called in a debounced manner when article content size changes
     func restoreStateIfNecessaryOnContentSizeChange() {
         guard isRestoringStateOnNextContentSizeChange else {
             return
         }
+        isRestoringStateOnNextContentSizeChange = false
         let scrollPosition = CGFloat(article.viewedScrollPosition)
         guard scrollPosition < webView.scrollView.bottomOffsetY else {
             return
         }
-        isRestoringStateOnNextContentSizeChange = false
         restoreState()
     }
     
+    /// Scroll to the state restoration scroll position now, canceling any previous attempts
     @objc func restoreState() {
         NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(restoreState), object: nil)
         let scrollPosition = CGFloat(article.viewedScrollPosition)

        }
        setWebViewHidden(false, animated: true)
    }
    
    func setWebViewHidden(_ hidden: Bool, animated: Bool, completion: ((Bool) -> Void)? = nil) {
        let block = {
            self.webView.alpha = hidden ? 0 : 1

    
    // MARK: State Restoration
    
    /// Save article scroll position for restoration later
    func saveArticleScrollPosition() {
        getVisibleSection { (sectionId, anchor) in
            assert(Thread.isMainThread)
