Added new options at end to improve calculation of gradient. Still unresolved which is best.