Add some flag checking