Change to Square matrices for most..

previously, the A matrix was being built as a size(xd) by size(xc)
matrix when it should have been a square(size(xc)) matrix.   Fixed
(except for two of them