fix some logical bug, and complet the state transfer.