Initial bitflags migration

I had an initial stab at this, basically picking the easiest looking thing in that gist. 

This is really just a sanity check for the approach, although I'm pretty tempted to do this in small chunks at least at first to see what the impact is in 3rd parties.

Updates #14207
/cc @aturon