some minor error-handling improvements