Adding gradients and minor fixes

Feat @Larry006
I'm not sure this will work