fix some detection bugs.