fixed all memory leaks