Various changes to compile for Visual Studio 2012. Ported build system from cppkit.