statistics: tidy up and document