Fixed bugs with batch handling