fix momery leak (partly fix, memory leak still exist).