Correctly scope local variables used.