Some cleanups and refactoring in the multiplexer worker