Some optimization in the Detection class