find a few more edge cases, plus fix the apparently greatly increased mess of "state_id"s.