Various improvements/fixes for logging