Make the serialization transformer a little smarter and better organized.

BUG=
R=rnystrom@google.com

Review URL: https://codereview.chromium.org/656973002