Restructure, put statistics in functions