Fixing implicitly declared globals. Code reformatting. Etc.

Removing seemingly unused variables