fix minor bugs on generating state
fix minor bugs