plugging memory leaks