added a function to compute rref and minor book-keeping changes