/* Move to appropriate scan state */
        jlink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT);
 
-       jlink_state_move();
+       /* Only move if we're not already there */
+       if (tap_get_state() != tap_get_end_state())
+               jlink_state_move();
+
        jlink_end_state(saved_end_state);
 
        /* Scan */
 
        int num_states = cmd->num_states;
        int state_count;
 
+       /* There may be queued transitions, and before following a specified
+          path, we must flush those queued transitions */
+       usbprog_jtag_tms_send(usbprog_jtag_handle);
+
        state_count = 0;
        while (num_states)
        {
                usbprog_write(0, 0, 0);
        }
 
+#ifdef _DEBUG_JTAG_IO_
+       LOG_DEBUG("runtest: cur_state %s end_state %s", tap_state_name(tap_get_state()), tap_state_name(tap_get_end_state()));
+#endif
+
        /* finish in end_state */
        /*
        usbprog_end_state(saved_end_state);
        else
                usbprog_end_state(TAP_DRSHIFT);
 
-       /* usbprog_jtag_tms_send(usbprog_jtag_handle); */
+       /* Only move if we're not already there */
+       if (tap_get_state() != tap_get_end_state())
+               usbprog_state_move();
 
-       usbprog_state_move();
        usbprog_end_state(saved_end_state);
 
        usbprog_jtag_tms_send(usbprog_jtag_handle);
        }
        f(usbprog_jtag_handle, (char *)buffer, scan_size);
 
+       /* The adapter does the transition to PAUSE internally */
        if (ir_scan)
                tap_set_state(TAP_IRPAUSE);
        else