Logging to logfile rather than printing to console.
Cleaned up run loop