adding compiling with debug symbol and fix some memleaks