Misc fixes to allow building/runtime errors on VS2013