Possible fix for mem leaks