TEZ-1701. ATS fixes to flush all history events and also using batching. (hitesh)