lots of memory leaks fixed!