Replaced SparseVector arrays with SparseMatrix