Covariance matrix NaN bug fixed