VS2012 migration

(and introduced some bugs :) )