spark: improve support for older versions