Adding some memory output, and cleanup routines