NN memory leak fix