Add retrieval of state and logging.