Improve debug logging:

  - Add a debugfile config parameter;
  - etc.