Trying to fix memory leak for whern loading large datasets