Improvements to serializer code to facilitate unserialization

Change-Id: I25194a3001fcb1800456f603f36116ba57efacfc