Add retrieveState API for debugging.