Fix batch usage memory leaks