Move out (de)serialization code to Serializers

Change-Id: I8f5ff0944dfb97a84369476d05a1bc3355e4ce41