Fixed multitude of memory leaks