Fix potential bug and force setting state before sending signal