fixed memory leaks in client