Support linked gradients.

Closes #441.