Improve SSM code health

Lots of little changes that shouldn't alter the way the code works (though the change to the logging commands might reduce overhead for messages that aren't logged).

- Change string formatting to arguments in logging commands as it is the
  way logging is meant to be called.
- Tidy some whitespace.
- Change `not x in y` tests to `x not in y`.