 			// prepare for moving left
 			switch (role) {
 			case LEFT:
-				WriteParticle(&going_left, cur_left_outgoing);
-				--cur_left_outgoing;
+				WriteParticle(&going_left, left_outgoing + (cur_L_outgoing_written++ & BUFFER_MOD));
 				break;
 			case RIGHT:
-				*here = *(cur_right_incoming++);
+				if (cur_R_incoming_read < cur_R_incoming_written)
+					*here = right_incoming[cur_R_incoming_read++ & BUFFER_MOD];
 				break;
 			case END:
 				if (going_right.color)

			// prepare for moving right
			switch (role) {
			case LEFT:
				*here = *(cur_left_incoming--);
				break;
			case RIGHT:
				WriteParticle(&going_right, cur_right_outgoing);
				++cur_right_outgoing;
				break;
			case BEGINNING:
				if (going_left.color)

#include <stdio.h>
#include "../testharness/testharness.h"

#define BLOCK 416
#define BUFFER_SIZE 256
#define TRANSFER_SIZE 16
#define BUFFER_MOD 255
#define _2XBUFFER_SIZE (BUFFER_SIZE * 2)
#define MAX_MOMENTUM 0xF
#define MOMENTUM_INIT 0xF0000000
