added avg_n and other statistics. Not working right at the moment, try to solve these