Added comments and more logging.