Revert back flag values on any error