resolved a few memory leaks