Use functional replace to processes gradients too
Merge pull request #22 from benjojo/gradients

Support gradients