Refactoring: Change the scope of variables to local as much as possible.