 
     // state
     private var _isDisposed = false
-    private var _observers = Bag<AnyObserver<Element>>()
-    private var _stoppedEvent: Event<Element>?
-    private var _stopped = false
+    private var _observers = Bag<(Event<Element>) -> ()>()
+    private var _isStopped = false
+    private var _stoppedEvent = nil as Event<Element>? {
+        didSet {
+            _isStopped = _stoppedEvent != nil
+        }
+    }
     private var _lastValue: Element?
 
     /// Indicates whether the subject has been disposed.


    func _synchronized_on(_ event: Event<E>) {
        _lock.lock(); defer { _lock.unlock() }
        if  _isDisposed || _stopped {
            return
        }


        
        case .error:
            _stoppedEvent = event

            let observers = _observers
            _observers.removeAll()
            _lock.unlock()

            dispatch(observers, event)
        
        case .completed:
            _stoppedEvent = event

            let observers = _observers
            _observers.removeAll()
            _lock.unlock()

            if let lastValue = _lastValue {
                dispatch(observers, .next(lastValue))
            }

            dispatch(observers, event)
        }
    }

