Set name directly after incrementing counter.
Use counter rather than manually-managed dict.