Standardize WriteMatrix
Clean up dead code
Clean