Code and logging cleanup