threading working, leaking memory though