Fix flag logic.