Ron,
I noticed that the results change to layer 0, shouldn't this check to see what layer the lines are drawn on, as well as what color, to match them? Just a thought, but very cool routine.
Edit: Actually, it was the color, if it is hard coded that would change.