TSRM related speed optimization - thanks to patch from NewEraCracker
win32 fix from NewEraCracker
more win32 related fixes