Merge pull request #6029
a784f90 Cap nAttempts penalty at 8 and switch to pow instead of a division loop. (Gregory Maxwell)