Cache option flags and check them first.
Merge pull request #373 from Dmitry-Me/cacheOptionFlagsAndCheckThemFirst

Cache option flags and check them first.