fixed some minor memory leaks