logging matrix sparsity and fix some js bugs