improved sparsity detection by checking for constants