More memory efficient implementation of data loader