Fixed key list comprehension and improved logging.