Correctly rolls back insertion if something fails