macrorun summarize: refactor useful functions in the lib. Also preparation of the rank command.