Fixed memmory leaks