Wrapping and unwrapping messages