Fix bug in safebatch