Added more code for statistics functions.