PeterH:
I don't know, but I would guess that the problem is similar to the issue of switching the ADC MUX to a different input and trying to take a sample immediately.If the analog reference voltage is set once and then remains constant, I would have thought that setting the analog reference repeatedly to the same value was unnecessary but harmless, and I not have thought it was necessary to allow any extra 'settling time' before taking a sample.
I don't like the idea of setting ADMUX over and over again, but since the code is a function designed to read whatever port is specified, I don't see how to get around it.