Fixed diagonal code so that it work for arbitrary number of frequency channels.