This was more challenging than the prior parts, but I have sectors working properly, including the joints between them and allowing the player to move the head of the program through its own sectors, which was a difficult mechanic to get right. Obligatory video:
I did this by storing the position of each sector in an array, in chronological order. It pops the last sector from the list if the length of the array is greater that the maximum program size.
For the joints/squares that connect each sector in the same program, I iterate through each sector position and, if two squares are adjacent in a row or column, draw a translucent rectangle between them. With every move, I clear them and redraw them. There might be a more efficient way to do it, but I couldn’t be bothered to work it out.