Added most of the logging stuff