Moved serialization into helper methods and updated them with the latest API sepecifications.