More defect detection fixes