clean up detect.c