Made some minor changes to reduce the potential for crashes
Added a submatrix function
Merge branch 'Ben's-Branch'