Fixes for MSVC

Now that MERGE_STATIC_LIBRARIES is gone, which required to most intrusive changes in my last pull request, and I had some time at hand, here is another attempt at getting stp/master to compile with MSVC (Visual Studio 2012). I tried to keep the changes minimal. I also didn't do any functional testing on windows yet. I only tried to make it compile for now.

If you're not willing to merge all of the changes right now, I'd be happy if you at least cherry-picked the non-controversial ones.