Moved serialisation portion inside wrapper to simplify API code