Bug fix and better logging.