Save codes with the same format they are on the server

Prior to this, codes were initialized with a format optimized for client-side use, but then persisted with that same format. This PR isolates the client-side formatting of the codes to the Codes collection itself, and persists codes in the format the server should expect.