Code now only uses square matrices.