Cleaning up gradient descent code part 1.