Still working on memory leaks in the matrix() function.  valgrind shows leaks there, and smaller leaks in some
print statements (which can be expunged later...)