Re-order of functions. Moving reduce to a better place.