Also make previous commit work for SMART_ACTION_REMOVE_UNIT_FLAG and move it into a separate function.