Fix flag setting