Covariance matrix handling and few fixes