Fix for issue #18: bySum was not working correctly. (Thanks to @stevechc)