Some changes to clean up correctly after error conditions.
Added forgotten code for first snapshot case.