First try at rewriting the gradient.