Is there some way to consolidate this logic for adhoc? It is awkward that we serialize this one part of the code base and then deserialize so far away based on sets of flags in both cases.