Thanks very much Gilles

. Could you be so kind as to email me patches for these instead or provide a git branch that I could pull off? That would be most helpful.
No problem, but that will take until next week.
Gilles
Note - you don't need to do the last 3.5 rounds of calculation to be able to determine if a hash is a share.
See here for discussion of that and other optimisations elsewhere in the thread:
https://bitcointalk.org/index.php?topic=7964.msg455128#msg455128(My last Edit of that and a few posts above that one for the discussion)
Also the comments about setting up the beginning of the hash process that is common across multiple calls