replaced gatherratesfewpartitions with a hybrid version that comprises less code, but may computationally be less efficient. Not testing yet, but seems to work