Updated comments, added some logging.