Fix bug in sample covariance