Added slightly better error reporting