Rewrote pipes to use a 2-dimensional array for easier coding and fewer counter variables.