KVO to compute the gradient

I did this fix quickly, there might be a better fix, though. I
preferred the overridden setters, though. Anyway, thanks.