sparse matrix building improved (with dirty but sufficient code :P)