Fixed memory leaks related to use of scaleNN.