still trying to fix mem leaks