Improved memory usage in the DataGenerator