Fixed potential race condition in batch transformer