protect save_state and clear_error