made small changes to logging and exceptions