Added several statistics functions and did some refactoring