clean up some resource leaks