Check for null device id (fix #625)