Flag code refactored.