detection.py fixes