Fix ordering and idempotency

Couple of fixes from issues I've come across in work code.