global cleanup and debugging