Set flags correctly