Patch to support MSVC correctly, contributed by Morten Ofstad!