Improved flags management.