Cleanup shut down process.   General code cleanup.