VC12 fixes by @dalkon