Changed the logging around slightly to make it easier to reuse