Fix a lot of whitespace and localize some more variables.