fix memmory leaks