refactoring + vs2013 fixes