added memory debugging to find leaks