api.c correct DEVICECODE and ordering