fixed memory leak issues