Some improvements to dection handling