Freeing memory for no memory leaks