Rename variables in inner scope to avoid shadowing outer variables of the same name.

Discovered with -Wshadow