Matrix cleanup