Ported to vc11(visual studio 2012); Fixed memory leaks