Original patch written by David Anderson (original r from Fyren). - Updated to function with the current JIT compiler. - Took in clean-ups from later-dated patches.