Rewrite Rank.serialization to use a switch.