Fixed memory deallocation error, now fix segfault