Improve code health of medium offenders

- Change string formatting to argument in the logging commands.
- Remove unused imports.
- Tidy some white space.
- Change 'not x is y' tests to 'x is not y'.