fixed warnings and memory leak