Wrote a Matrix class and fixed all uses of it, as well as other small fixes like...