preliminary work on gradients, not completely up-to-date