Add safe reset function.