Reorganized message parsing end encoding.