merge changes to sgminer.c from v5_0