Refactoring of linear algebra part 2