Clean up. Fix potential logging bug.