Added better handling of multiple channels.