As the setgenerate command was set to no longer require a wallet, shouldn't a check for pWallet be added here? (or can the mining thread run without wallet as well, I wouldn't know for sure)