Fixed bug in fitting covariance matrix