Re-factored the logging and fixed a broken integration test.