More logging.
Some more error checking