fixed up some small memory leaks.
Output some resource stats when shutting down. Just for a quick overview.
more memory leak fixes.