Tested, improved logging.