Fixing more leaking memory/segfaults