Move out serialization code to another component

Change-Id: I8de5a6c634196fb94becee2689a7f1e33d6bf6ca