use RAII for startBatch and commitBatch, for exception safety and errorproneness reduction