Refactoring of the message handling infrastructure