Fixed many errors in the multiplexer main loop.