Merge pull request #36 from mbrubake/master

New pattern to reduce code duplication in mixed-type agrad functions.