Add Batching function

Add Batching function
Fix some bugs of batching

Fix some bugs of batching after dns error