clean up work, fixing memory leaks