Fix logic loops while processing grids of wires