Fix potential bugs in restoring newdecl state.