fix some memleaks & uninitialized vars & unused vars