Restructure a bit and small improvements on duplication detection
Bug solve of duplication, should be finished now
write duplications to file