marginally better error reporting and other fixes