Use buid-in couch reduce functions when possible.
Merge pull request #4225 from HassenRiahi/UseBuildInReduce

Use buid-in couch reduce functions when possible.