Improve writing of stats and add algorithm to output.