Refactor reduce.
Merge pull request #8 from soloman817/master

Refactor reduce.