Converted to VS2012 and fixed compilation weirdness.
Basic main loop