replaced all C-like malloc
fixed QThread deletion issue