better error handling, better logs, misc