Ported most of functionality to windows (warning: windows target does not link)