Cleanup flags sven

this is to get #7551 updated for merge.

I've added the missing non-global validation functions, and rebased