Better encoding of flags