fix bugs and upgrade to VS2013