fixed three memory leaks