Remove another unused import.
Remove StringIO/use less temporaries in prepare_batch.