[PATCH] Implement a better mean and standard deviation calculation