Fixed numerous serious errors

Building on windows works now
Visual Studio 2012 project