overhaul logging and error handling (#416)