Alright. I didn't want to touch that code too much, but I think I fully understand it now, so I'll tweak it as you are suggesting.

Regarding the 64 bit thing, I'm not comfortable with changing anything there, so I'll just leave it as is, and maybe leave a TODO in there or something.