Extract serializer alternation resolution.

Extract serializer alternation resolution to a function.

Closes #158.