After hours of testing with the new AWP debugger, it seems the problem is not the looper but the fact that there is a thumbnail control in the looper. I could not understand why all the server code was executing multiple times. This does cause the page to load very slowly and I think that is related to the second page showing the wrong thumbnail images on the second page (original problem).
I have page with thumbnail controls and that page executes the server code once for each thumbnail control.
However, the new AWP context functions work great.