moved control of top-n from sorter to cleanup().