Fix bug where reduce operation changes to map if reduce function returns undefined.