Cleaned up and improved logging.