Fixed bugs and improved the batch_loader