merging in the improved logging code