minor corrections to flag checking