Merge win32thread into master

win32thread branch has some crucial changes that are not present in master, namely win32 platform fixes necessary because of some recent changes regarding Linux code.