Refactor of messaging pipeline