Adds serialize function for async methods.