Fixed the gradient generator. Now working properly, ready for the next steps.