fix warns and memory leak