fixed some memory leaks, still work to do on that