fix buffer overflow
fix memory leaks