rmd some debug statements, added a writeMatrix function