starting to correct memory leaks