Added some more sophsticated logging around various parts of the code base