Some cleanup of local vars and logging