made some progress on error handling; but some of it is kludgy. error handling is always tricky...