Some code changes to try and test the gradient. Still not working right *sigh*.
New attempt of making it work.
Debug calls doesn't show any kind of progress.