Adding reduce function
Small changes
Javadoc and fixing variable names
Merge pull request #5 from fernandomantoan/master

Reduce