Some clean-up of detection process.