fix derivatives for products with zero terms