Fixed segfault when there is empty batch