     public func transitionToState(_ state: ViewStateMachineState, animated: Bool = true, completion: (() -> ())? = nil) {
         lastState = state
         
-        queue.async {
-            if state == self.currentState {
+        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
-            self.queue.suspend()
-            self.currentState = state
+            strongSelf.queue.suspend()
+            strongSelf.currentState = state
             
             let c: () -> () = {
-                self.queue.resume()
+                strongSelf.queue.resume()
                 completion?()
             }
             

	}

    fileprivate func hideAllViews(animated: Bool, completion: (() -> ())? = nil) {
        let animations: () -> () = {
            for (_, view) in self.viewStore {
                view.alpha = 0.0
            }
        }
        
        let animationCompletion: (Bool) -> () = { (finished) in
            for (_, view) in self.viewStore {
                view.removeFromSuperview()
            }
            

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