fix bad logging and add more error reporting