Code cleanup

I was doing some profiling to help us with memory leaks. This is the results of that work.