first part done
error checking in place
small fix
Merge pull request #1684 from Kenneth-T-Moore/deriv

Better control of and handling for forward vs adjoint