Added linear method to matrix. Improved sanity checks