Memory Leaks

Fixes part of the memory leaks that occur when program runs for a long
time.