Added retainTopNpeaks() functions