Fix refactoring bug in several matrix methods