Fixed some memory errors reported by valgrind. These were mainly just
the malloc'd items not be freed on exit, which I knew about. Decided to
add a temp fix to this anyway.