Got reduce() working... finally.  Right now its written very clumsily, but I wanted to save this.