Some tidy-up and logging changes