a few cleanups and use tee to log to screen and file.