Logging improvements

Making infrastructure internal and fixing tests.