Optimization of the way of calculating MinCq matrices. Much more efficient now!