Bug in gradient computation fixed and memory allocation clarified.