Improve sparse matrix support, add logging support.