Fix for memory leak