Let reduceByKey to take care of local combine

Also refactored some heavy FP code to improve readability and reduce memory footprint.