Fixed win32 compiler issues + reimplemented win32 threading