Defect control at the nanoscale