Refactoring matrix-matrix multiplications