Uninitialized memory and leaks that valgrind was complaining about