Adding gradients and minor fixes

Feat @Larry006
I will wait for further instructions then!