cleaning and making order in squarematrix.d