  	int tmp;
  
  	int type = AVA2_GETS_ERROR;
-@@ -209,7 +277,7 @@ static int decode_pkg(struct thr_info *thr, struct avalon2_ret *ar, uint8_t *pkg
- 
- 		memcpy(&modular_id, ar->data + 28, 4);
- 		modular_id = be32toh(modular_id);
--		if (modular_id == 3)
-+		if (modular_id > 3)
- 			modular_id = 0;
- 
- 		switch(type) {
-@@ -219,13 +287,12 @@ static int decode_pkg(struct thr_info *thr, struct avalon2_ret *ar, uint8_t *pkg
+@@ -232,7 +287,6 @@ static int decode_pkg(struct thr_info *thr, struct avalon2_ret *ar, uint8_t *pkg
  			memcpy(&nonce2, ar->data + 8, 4);
  			/* Calc time    ar->data + 12 */
  			memcpy(&nonce, ar->data + 16, 4);

 
 	struct pool *pool;
 	struct cgpu_info *avalon2 = thr->cgpu;
@@ -681,35 +826,34 @@ static int64_t avalon2_scanhash(struct thr_info *thr)
 	uint32_t tmp, range, start;
 	int i;
 

 	}
 	return h * 0xffffffff;
 }
@@ -783,18 +915,11 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
 	int i, j, a, b;
 	char buf[24];
 	double hwp;
-	int devtype[AVA2_DEFAULT_MODULARS];
 	int minerindex, minercount;
 
 	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
-		devtype[i] = AVA2_ID_AVAX;
-		if (!strncmp((char *)&(info->mm_version[i]), AVA2_MM_VERNULL, 4))
+		if(info->dev_type[i] == AVA2_ID_AVAX)
 			continue;
-		if (!strncmp((char *)&(info->mm_version[i]), AVA2_FW2_PREFIXSTR, 2))
-			devtype[i] = AVA2_ID_AVA2;
-		if (!strncmp((char *)&(info->mm_version[i]), AVA2_FW3_PREFIXSTR, 2))
-			devtype[i] = AVA2_ID_AVA3;
-
 		sprintf(buf, "ID%d MM Version", i + 1);
 		root = api_add_string(root, buf, &(info->mm_version[i]), false);
 	}
@@ -802,15 +927,15 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
 	minerindex = 0;
 	minercount = 0;
 	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
-		if (devtype[i] == AVA2_ID_AVAX) {
+		if (info->dev_type[i] == AVA2_ID_AVAX) {
 			minerindex += AVA2_DEFAULT_MINERS;
 			continue;
 		}
 
-		if (devtype[i] == AVA2_ID_AVA2)
+		if (info->dev_type[i] == AVA2_ID_AVA2)
 			minercount = AVA2_DEFAULT_MINERS;
 
-		if (devtype[i] == AVA2_ID_AVA3)
+		if (info->dev_type[i] == AVA2_ID_AVA3)
 			minercount = AVA2_AVA3_MINERS;
 
 		for (j = minerindex; j < (minerindex + minercount); j++) {
@@ -821,19 +946,19 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
 	}
 
 	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
-		if(devtype[i] == AVA2_ID_AVAX)
+		if(info->dev_type[i] == AVA2_ID_AVAX)
 			continue;
 		sprintf(buf, "Local works%d", i + 1);
 		root = api_add_int(root, buf, &(info->local_works[i]), false);
 	}
 	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
-		if(devtype[i] == AVA2_ID_AVAX)
+		if(info->dev_type[i] == AVA2_ID_AVAX)
 			continue;
 		sprintf(buf, "Hardware error works%d", i + 1);
 		root = api_add_int(root, buf, &(info->hw_works[i]), false);
 	}
 	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
-		if(devtype[i] == AVA2_ID_AVAX)
+		if(info->dev_type[i] == AVA2_ID_AVAX)
 			continue;
 		a = info->hw_works[i];
 		b = info->local_works[i];
@@ -843,31 +968,31 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
 		root = api_add_percent(root, buf, &hwp, true);
 	}
 	for (i = 0; i < 2 * AVA2_DEFAULT_MODULARS; i++) {
-		if(devtype[i/2] == AVA2_ID_AVAX)
+		if(info->dev_type[i/2] == AVA2_ID_AVAX)
 			continue;
 		sprintf(buf, "Temperature%d", i + 1);
 		root = api_add_int(root, buf, &(info->temp[i]), false);
 	}
 	for (i = 0; i < 2 * AVA2_DEFAULT_MODULARS; i++) {
-		if(devtype[i/2] == AVA2_ID_AVAX)
+		if(info->dev_type[i/2] == AVA2_ID_AVAX)
 			continue;
 		sprintf(buf, "Fan%d", i + 1);
 		root = api_add_int(root, buf, &(info->fan[i]), false);
 	}
 	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
-		if(devtype[i] == AVA2_ID_AVAX)
+		if(info->dev_type[i] == AVA2_ID_AVAX)
 			continue;
 		sprintf(buf, "Voltage%d", i + 1);
 		root = api_add_int(root, buf, &(info->get_voltage[i]), false);
 	}
 	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
-		if(devtype[i] == AVA2_ID_AVAX)
+		if(info->dev_type[i] == AVA2_ID_AVAX)
 			continue;
 		sprintf(buf, "Frequency%d", i + 1);
 		root = api_add_int(root, buf, &(info->get_frequency[i]), false);
 	}
 	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
-		if(devtype[i] == AVA2_ID_AVAX)
+		if(info->dev_type[i] == AVA2_ID_AVAX)
 			continue;
 		sprintf(buf, "Power good %02x", i + 1);
 		root = api_add_int(root, buf, &(info->power_good[i]), false);
@@ -876,6 +1001,46 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
 	return root;
 }
 
