Added debug logging for exit code