Better handling in token function for inputs that are not arrays or strings.