fixes to matrix handling (several were transposed.)  Also, fixing several function signature mismatches.