Cleaned up some code around logging