Improved and extended sparsefuncs.