Clean up various compiler warnings
Clean up some memory leaks