Updates for adding logging.
Updated with the pull from Ryan's code.