minor polish, logging and error handling