Batch insert bug fix