Could you add a comment on why this flag can soundly be computed this way? The logic is quite spread out, or it's at least not obvious to me.