Make map and reduce more flexible with types.