Added stats.c - simple statistics calculations