restructured message handling.