Making some very minor improvements to loops and by adding 'final' in some
places.
Authored by: nerius 2023-10-07
Parent: [r1214]
Child: [r1216]