First working version of sparsification.