partial port to VC++ 2013