 
 /// Zips elements of two signals into pairs. The elements of any Nth pair
 /// are the Nth elements of the two input signals.
-public func zipWith<T, U, E>(otherSignal: Signal<U, E>)(signal: Signal<T, E>) -> Signal<(T, U), E> {
-	return Signal { observer in
-		let initialStates: (ZipState<T>, ZipState<U>) = (ZipState(), ZipState())
-		let states: Atomic<(ZipState<T>, ZipState<U>)> = Atomic(initialStates)
-		
-		let flush = { () -> () in
-			var originalStates: (ZipState<T>, ZipState<U>)!
-			states.modify { states in
-				originalStates = states
+public func zipWith<T, U, E>(otherSignal: Signal<U, E>) -> Signal<T, E> -> Signal<(T, U), E> {
+	return { signal in
+		return Signal { observer in
+			let initialStates: (ZipState<T>, ZipState<U>) = (ZipState(), ZipState())
+			let states: Atomic<(ZipState<T>, ZipState<U>)> = Atomic(initialStates)
+			
+			let flush = { () -> () in
+				var originalStates: (ZipState<T>, ZipState<U>)!
+				states.modify { states in
+					originalStates = states
+					
+					var updatedStates = states
+					let extractCount = min(states.0.values.count, states.1.values.count)
+					
+					removeRange(&updatedStates.0.values, 0 ..< extractCount)
+					removeRange(&updatedStates.1.values, 0 ..< extractCount)
+					return updatedStates
+				}
 				
-				var updatedStates = states
-				let extractCount = min(states.0.values.count, states.1.values.count)
+				while !originalStates.0.values.isEmpty && !originalStates.1.values.isEmpty {
+					let left = originalStates.0.values.removeAtIndex(0)
+					let right = originalStates.1.values.removeAtIndex(0)
+					sendNext(observer, (left, right))
+				}
 				
-				removeRange(&updatedStates.0.values, 0 ..< extractCount)
-				removeRange(&updatedStates.1.values, 0 ..< extractCount)
-				return updatedStates
+				if originalStates.0.isFinished || originalStates.1.isFinished {
+					sendCompleted(observer)
+				}
 			}
 			
-			while !originalStates.0.values.isEmpty && !originalStates.1.values.isEmpty {
-				let left = originalStates.0.values.removeAtIndex(0)
-				let right = originalStates.1.values.removeAtIndex(0)
-				sendNext(observer, (left, right))
-			}
+			let onError = { sendError(observer, $0) }
+			let onInterrupted = { sendInterrupted(observer) }
 			
-			if originalStates.0.isFinished || originalStates.1.isFinished {
-				sendCompleted(observer)
-			}
-		}
-		
-		let onError = { sendError(observer, $0) }
-		let onInterrupted = { sendInterrupted(observer) }
-		
-		let signalDisposable = signal.observe(next: { value in
-			states.modify { (var states) in
-				states.0.values.append(value)
-				return states
-			}
+			let signalDisposable = signal.observe(next: { value in
+				states.modify { (var states) in
+					states.0.values.append(value)
+					return states
+				}
+				
+				flush()
+			}, error: onError, completed: {
+				states.modify { (var states) in
+					states.0.completed = true
+					return states
+				}
+					
+				flush()
+			}, interrupted: onInterrupted)
 			
-			flush()
-		}, error: onError, completed: {
-			states.modify { (var states) in
-				states.0.completed = true
-				return states
-			}
+			let otherDisposable = otherSignal.observe(next: { value in
+				states.modify { (var states) in
+					states.1.values.append(value)
+					return states
+				}
 				
-			flush()
-		}, interrupted: onInterrupted)
-		
-		let otherDisposable = otherSignal.observe(next: { value in
-			states.modify { (var states) in
-				states.1.values.append(value)
-				return states
-			}
+				flush()
+			}, error: onError, completed: {
+				states.modify { (var states) in
+					states.1.completed = true
+					return states
+				}
+					
+				flush()
+			}, interrupted: onInterrupted)
 			
-			flush()
-		}, error: onError, completed: {
-			states.modify { (var states) in
-				states.1.completed = true
-				return states
-			}
-				
-			flush()
-		}, interrupted: onInterrupted)
-		
-		return CompositeDisposable(ignoreNil([ signalDisposable, otherDisposable ]))
-	}
-}
-
-internal func zipWith<T, E>(otherSignal: Signal<T, E>)(signal: Signal<[T], E>) -> Signal<[T], E> {
-	return signal |> zipWith(otherSignal) |> map { $0.0 + [$0.1] }
+			return CompositeDisposable(ignoreNil([ signalDisposable, otherDisposable ]))
+		}
+	}
+}
+
+internal func zipWith<T, E>(otherSignal: Signal<T, E>) -> Signal<[T], E> -> Signal<[T], E> {
+	return { signal in
+		return signal |> zipWith(otherSignal) |> map { $0.0 + [$0.1] }
+	}
 }
 
 /// Applies `operation` to values from `signal` with `Success`ful results
 /// forwarded on the returned signal and `Failure`s sent as `Error` events.
-public func try<T, E>(operation: T -> Result<(), E>)(signal: Signal<T, E>) -> Signal<T, E> {
-	return signal |> tryMap { value in
-		return operation(value).map {
-			return value
+public func try<T, E>(operation: T -> Result<(), E>) -> Signal<T, E> -> Signal<T, E> {
+	return { signal in
+		return signal |> tryMap { value in
+			return operation(value).map {
+				return value
+			}
 		}
 	}
 }
 
 /// Applies `operation` to values from `signal` with `Success`ful results mapped
 /// on the returned signal and `Failure`s sent as `Error` events.
-public func tryMap<T, U, E>(operation: T -> Result<U, E>)(signal: Signal<T, E>) -> Signal<U, E> {
-	return Signal { observer in
-		signal.observe(next: { value in
-			operation(value).analysis(ifSuccess: { value in
-				sendNext(observer, value)
-			}, ifFailure: { error in
+public func tryMap<T, U, E>(operation: T -> Result<U, E>) -> Signal<T, E> -> Signal<U, E> {
+	return { signal in
+		return Signal { observer in
+			signal.observe(next: { value in
+				operation(value).analysis(ifSuccess: { value in
+					sendNext(observer, value)
+				}, ifFailure: { error in
+					sendError(observer, error)
+				})
+			}, error: { error in
 				sendError(observer, error)
-			})
-		}, error: { error in
-			sendError(observer, error)
-		}, completed: {
-			sendCompleted(observer)
-		}, interrupted: {
-			sendInterrupted(observer)
-		})
+			}, completed: {
+				sendCompleted(observer)
+			}, interrupted: {
+				sendInterrupted(observer)
+			})
+		}
 	}
 }
 

	var completed = false
}

private func observeWithStates<T, U, E>(signalState: CombineLatestState<T>, otherState: CombineLatestState<U>, lock: NSRecursiveLock, onBothNext: () -> (), onError: E -> (), onBothCompleted: () -> (), onInterrupted: () -> ())(signal: Signal<T, E>) -> Disposable? {
	return signal.observe(next: { value in
		lock.lock()



/// Forwards all events onto the given scheduler, instead of whichever
/// scheduler they originally arrived upon.
public func observeOn<T, E>(scheduler: SchedulerType) -> Signal<T, E> -> Signal<T, E> {
	return { signal in
		return Signal { observer in
			return signal.observe(Signal.Observer { event in
