Attempting to fix some possible memory leaks. Son't know if I'm actually
helping anything though.