Some fixes from debugging, with logging.