Question: how to rref a matrix?
Answer: Identify the last row having a pivot equal to 1, and let this be the pivot row.
Add multiples of the pivot row to each of the upper rows, until every element above the pivot equals 0.