Initial version of mapreduce functions.