moved the defectwindow code into the main lib