Optimized flags

Credit to pbeeler