Simplify code for handling edges with multiple outputs from #2.

Instead of first producing a list with entries for every log line and
then filtering out lines with the same hash in a second pass, do both in
as single pass. No functional change.
move class Threads closer to its use, no functional change