Fixed bug with memory allocation and standard deviation