Tidy up logging and exceptions