Slightly better error checking.