Fix batch sleep bug and reset counter when reused