elemental: refactor flag handling for upkeep