WIP Further merge of win32 and linux code