Fix global variable pollution, lint errors, etc.