Logging to file; bugfix