             var disposable: Disposable?
             disposable = self.subscribe { result in
                 if counter < first {
+                    counter += 1
                     observer(result)
-                    counter += 1
                 } else {
                     disposable?.dispose()
                     disposable = nil

            var lastValue: ValueType?

            return self.subscribe { result in
                if let lastValue = lastValue, !isEqual(lastValue, result) {
                    observer(result)
                } else {
                    if lastValue == nil {
                        observer(result)
                    }
                }
                
                lastValue = result
            }
        }
    }

        return Observable { observer in
            var prevValue: ValueType?
            return self.subscribe { result in
                let oldPrevValue = prevValue
                prevValue = result
                observer((result, oldPrevValue))
            }
        }
    }
