Fixed some bugs in batch mode.