started fixing memory leaks