fixed some minor meory leaks