More complicated version of summarize-clean.R Should be faster than the tapply version