   /// Usually used on the Signal resulting from `materialize()`.
   /// - SeeAlso: `errors()`, `materialize()`
   public func elements<U, E>() -> Signal<U, NoError> where Element == Event<U, E> {
-    return flatMap { $0.element }
+    return compactMap { $0.element }
   }
 
   /// Returns an observable sequence containing only the unwrapped errors from `.failed` events.
   /// Usually used on the Signal resulting from `materialize()`.
   /// - SeeAlso: `elements()`, `materialize()`
   public func errors<U, E>() -> Signal<E, NoError> where Element == Event<U, E> {
-    return flatMap { $0.error }
+    return compactMap { $0.error }
   }
 }
 

  }

  /// Map each event into a signal and then flatten inner signals.
  public func flatMapLatest<O: SignalProtocol>(_ transform: @escaping (Element) -> O) -> Signal<O.Element, Error> where O.Error == Error {
    return map(transform).switchToLatest()
  }

  /// Map each event into a signal and then flatten inner signals.
  public func flatMapMerge<O: SignalProtocol>(_ transform: @escaping (Element) -> O) -> Signal<O.Element, Error> where O.Error == Error {
    return map(transform).merge()
  }

  /// Map each event into a signal and then flatten inner signals.
  public func flatMapConcat<O: SignalProtocol>(_ transform: @escaping (Element) -> O) -> Signal<O.Element, Error> where O.Error == Error {
    return map(transform).concat()
  }

  /// Map failure event into another operation and continue with that operation. Also called `catch`.


extension SignalProtocol where Element: Sequence {

  @available(*, deprecated, renamed: "mapElement(_:)")
  public func flatMap<U>(_ transform: @escaping (Element.Iterator.Element) -> U) -> Signal<[U], Error> {
    return mapElement(transform)
  }

  /// Map each emitted sequence.
  public func mapElement<U>(_ transform: @escaping (Element.Iterator.Element) -> U) -> Signal<[U], Error> {
    return Signal { observer in
      return self.observe { event in
        switch event {
