Fixes style and adds an optional param 'numPartition' in distinct().