Handle cycling with dir=-1 correctly

Sorry, I overlooked this. At first I though the addition of the list's length was senseless because of the modulo, but later I had a brain wave what's the real reason for this ;-)

Btw: We call getIdentities() 4 times in this function. Do you think it's better to call just once and cache the result or it the overhead negligible?