Major fixes to detect commands