Fix bugs in modify &terminate flow