Minor modifications to flagging code