Added motion detection (debug) logic loop.