Improve code heath of worst offenders

- Change triple quoted comments to plain comments.
- Change string formatting to argument in the logging commands.
- Comment out unused import.
- Rename variable that clashes with built-in.
- Tidy some white space.