             DispatchQueue.main.sync {
                 switch state {
                 case .none:
-                    self.hideAllViews(animated: animated, completion: c)
+                    strongSelf.hideAllViews(animated: animated, completion: c)
                 case .view(let viewKey):
-                    self.showView(forKey: viewKey, animated: animated, completion: c)
+                    strongSelf.showView(forKey: viewKey, animated: animated, completion: c)
                 }
             }
         }

    // MARK: Private view updates
    
	fileprivate func showView(forKey state: String, animated: Bool, completion: (() -> ())? = nil) {
		if let newView = self.viewStore[state] {
			newView.alpha = animated ? 0.0 : 1.0
			let insets = (newView as? StatefulPlaceholderView)?.placeholderViewInsets() ?? UIEdgeInsets()
			let frame = view.frame
			newView.frame = CGRect(x: insets.left, y: insets.top, width: frame.width - insets.left - insets.right, height: frame.height - insets.top - insets.bottom)
			view.addSubview(newView)
		}

		let animations: () -> () = {
			if let newView = self.viewStore[state] {
				newView.alpha = 1.0
			}
		}

		let animationCompletion: (Bool) -> () = { (finished) in
			for (key, view) in self.viewStore {
				if !(key == state) {
					view.removeFromSuperview()
				}

    public func transitionToState(_ state: ViewStateMachineState, animated: Bool = true, completion: (() -> ())? = nil) {
        lastState = state
        
        queue.async { [weak self] in
            guard let strongSelf = self else { return }

            if state == strongSelf.currentState {
                return
            }
            
            // Suspend the queue, it will be resumed in the completion block
            strongSelf.queue.suspend()
            strongSelf.currentState = state
            
            let c: () -> () = {
                strongSelf.queue.resume()
                completion?()
            }
            
