Added reduce and mapreduce functions