Add more restrictive flag checking