Dataset statistics

rewrite of statistics