Moved 'seen' logic to datastructures.c and encapsulated