minor fixes and errmsg improvements