Final implementation of statistics. Adjusting of variable names to generalize and make code more understandable.