Create nicer filenames and avoid crashing on weird query.