added memory management for temporary matrices to MMM
almost no performance panelty