Fixed the History file to actually build.
Fixed the calculation of candidateHpwd to mod q in the end.