Initial port from MSVC