Fix optimization script
Optimizations for covariance