cleanups and debug output